changeset 1585:1655737bb7ad

merge with jdk8-b61
author mcimadamore
date Thu, 25 Oct 2012 23:25:08 +0100
parents ba59bf7fa23f (current diff) b47bb81ba962 (diff)
children 99ce7dc58473
files .hgtags src/share/classes/com/sun/source/tree/LambdaExpressionTree.java src/share/classes/com/sun/source/util/TreeScanner.java src/share/classes/com/sun/tools/javac/code/Kinds.java src/share/classes/com/sun/tools/javac/code/Printer.java src/share/classes/com/sun/tools/javac/code/Source.java src/share/classes/com/sun/tools/javac/code/Symbol.java src/share/classes/com/sun/tools/javac/code/Symtab.java src/share/classes/com/sun/tools/javac/code/Type.java src/share/classes/com/sun/tools/javac/code/TypeTags.java src/share/classes/com/sun/tools/javac/code/Types.java src/share/classes/com/sun/tools/javac/comp/Annotate.java src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/AttrContext.java src/share/classes/com/sun/tools/javac/comp/Check.java src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java src/share/classes/com/sun/tools/javac/comp/Enter.java src/share/classes/com/sun/tools/javac/comp/Flow.java src/share/classes/com/sun/tools/javac/comp/GraphInfer.java src/share/classes/com/sun/tools/javac/comp/Infer.java src/share/classes/com/sun/tools/javac/comp/InferFactory.java src/share/classes/com/sun/tools/javac/comp/LambdaToInnerClass.java src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java src/share/classes/com/sun/tools/javac/comp/LegacyInfer.java src/share/classes/com/sun/tools/javac/comp/Lower.java src/share/classes/com/sun/tools/javac/comp/MemberEnter.java src/share/classes/com/sun/tools/javac/comp/Resolve.java src/share/classes/com/sun/tools/javac/comp/TransTypes.java src/share/classes/com/sun/tools/javac/jvm/CRTable.java src/share/classes/com/sun/tools/javac/jvm/ClassFile.java src/share/classes/com/sun/tools/javac/jvm/ClassReader.java src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java src/share/classes/com/sun/tools/javac/jvm/Code.java src/share/classes/com/sun/tools/javac/jvm/Gen.java src/share/classes/com/sun/tools/javac/jvm/Items.java src/share/classes/com/sun/tools/javac/jvm/Pool.java src/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/share/classes/com/sun/tools/javac/parser/EndPosTable.java src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java src/share/classes/com/sun/tools/javac/parser/JavacParser.java src/share/classes/com/sun/tools/javac/parser/Lexer.java src/share/classes/com/sun/tools/javac/parser/Tokens.java src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java src/share/classes/com/sun/tools/javac/resources/compiler.properties src/share/classes/com/sun/tools/javac/tree/JCTree.java src/share/classes/com/sun/tools/javac/tree/Pretty.java src/share/classes/com/sun/tools/javac/tree/TreeInfo.java src/share/classes/com/sun/tools/javac/tree/TreeMaker.java src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java src/share/classes/com/sun/tools/javac/util/Bits.java src/share/classes/com/sun/tools/javac/util/List.java src/share/classes/com/sun/tools/javac/util/Log.java src/share/classes/com/sun/tools/javac/util/Names.java src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java test/tools/javac/6840059/T6840059.out test/tools/javac/7132880/T7132880.out test/tools/javac/Diagnostics/6722234/T6722234a_1.out test/tools/javac/Diagnostics/6722234/T6722234a_2.out test/tools/javac/Diagnostics/6722234/T6722234b_1.out test/tools/javac/Diagnostics/6722234/T6722234b_2.out test/tools/javac/Diagnostics/6722234/T6722234c.out test/tools/javac/Diagnostics/6799605/T6799605.out test/tools/javac/Diagnostics/6862608/T6862608a.out test/tools/javac/Diagnostics/6862608/T6862608b.out test/tools/javac/conditional/Conditional.java test/tools/javac/defender/DeprecatedDefenderSyntax.java test/tools/javac/defender/DeprecatedDefenderSyntax.out test/tools/javac/defender/Neg12.out test/tools/javac/diags/examples.not-yet.txt test/tools/javac/diags/examples/CantAccessArgTypeInFunctionalDesc.java test/tools/javac/diags/examples/CantAccessReturnTypeInFunctionalDesc.java test/tools/javac/diags/examples/CantAccessThrownTypesInFunctionalDesc.java test/tools/javac/diags/examples/CantApplyDiamond1.java test/tools/javac/diags/examples/CatchWithoutTry.java test/tools/javac/diags/examples/IncompatibleTypes1.java test/tools/javac/diags/examples/InferNoConformingAssignment.java test/tools/javac/diags/examples/InferredDoNotConformToLower.java test/tools/javac/diags/examples/KindnameConstructor.java test/tools/javac/diags/examples/UndeterminedType1.java test/tools/javac/diags/examples/WhereCaptured.java test/tools/javac/diags/examples/WhereCaptured1.java test/tools/javac/failover/CheckAttributedTree.java test/tools/javac/generics/diamond/neg/Neg06.out test/tools/javac/generics/diamond/neg/Neg07.out test/tools/javac/generics/inference/6315770/T6315770.out test/tools/javac/generics/inference/6611449/T6611449.out test/tools/javac/generics/inference/6638712/T6638712a.out test/tools/javac/generics/inference/6638712/T6638712b.out test/tools/javac/generics/inference/6638712/T6638712c.out test/tools/javac/generics/inference/6638712/T6638712d.out test/tools/javac/generics/inference/6638712/T6638712e.out test/tools/javac/generics/inference/6650759/T6650759m.out test/tools/javac/generics/inference/6838943/T6838943.out test/tools/javac/generics/inference/7086586/T7086586.out test/tools/javac/generics/inference/7086601/T7086601a.out test/tools/javac/lambda/BadBreakContinue.out test/tools/javac/lambda/BadConv03.out test/tools/javac/lambda/BadConv04.out test/tools/javac/lambda/BadExpressionLambda.out test/tools/javac/lambda/BadLambdaPos.out test/tools/javac/lambda/BadMethodCall.out test/tools/javac/lambda/BadRecovery.out test/tools/javac/lambda/BadReturn.out test/tools/javac/lambda/BadTargetType.out test/tools/javac/lambda/EffectivelyFinalTest.java test/tools/javac/lambda/EffectivelyFinalTest.out test/tools/javac/lambda/ErroneousArg.out test/tools/javac/lambda/LambdaConv09.out test/tools/javac/lambda/LambdaConv10.out test/tools/javac/lambda/LambdaConv21.out test/tools/javac/lambda/LambdaEffectivelyFinalTest.java test/tools/javac/lambda/LambdaEffectivelyFinalTest.out test/tools/javac/lambda/LambdaExpr10.out test/tools/javac/lambda/LambdaExpr19.out test/tools/javac/lambda/LambdaExprNotVoid.out test/tools/javac/lambda/MethodReference04.out test/tools/javac/lambda/MethodReference09.out test/tools/javac/lambda/MethodReference20.out test/tools/javac/lambda/MethodReference22.out test/tools/javac/lambda/MethodReference23.out test/tools/javac/lambda/MethodReference28.out test/tools/javac/lambda/MethodReference33.java test/tools/javac/lambda/MethodReference37.java test/tools/javac/lambda/MethodReference37.out test/tools/javac/lambda/MethodReference39.out test/tools/javac/lambda/MethodReference40.java test/tools/javac/lambda/MethodReference40.out test/tools/javac/lambda/MethodReference51.out test/tools/javac/lambda/MethodReference52.out test/tools/javac/lambda/MethodReference53.out test/tools/javac/lambda/MethodReferenceParserTest.java test/tools/javac/lambda/TargetType04.out test/tools/javac/lambda/TargetType06.out test/tools/javac/lambda/TargetType10.out test/tools/javac/lambda/TargetType11.out test/tools/javac/lambda/TargetType17.out test/tools/javac/lambda/TargetType20.out test/tools/javac/lambda/TargetType21.out test/tools/javac/lambda/TargetType24.out test/tools/javac/lambda/TargetType26.out test/tools/javac/lambda/TargetType27.out test/tools/javac/lambda/TargetType33.out test/tools/javac/lambda/TargetType36.java test/tools/javac/lambda/TargetType38.out test/tools/javac/lambda/TargetType39.out test/tools/javac/lambda/TargetType41.java test/tools/javac/lambda/TargetType41.out test/tools/javac/lambda/TargetType43.out test/tools/javac/lambda/TargetType44.out test/tools/javac/lambda/sqe/SAM_types/LambdaTest2_neg1.out test/tools/javac/lambda/sqe/SAM_types/NonSAM1.out test/tools/javac/lambda/sqe/SAM_types/NonSAM3.out test/tools/javac/lambda/sqe/lambdaExpression/AbstractClass_neg.out test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression3.out test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression4.out test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression5.out test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression6.out test/tools/javac/lambda/sqe/methodReference/MethodRef_neg.out test/tools/javac/lambda/sqe/typeInference/InferenceTest_neg5.out test/tools/javac/quid/T6999438.out test/tools/javac/typeAnnotations/newlocations/BasicTest.out test/tools/javac/varargs/6313164/T6313164.out
diffstat 352 files changed, 10001 insertions(+), 3596 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Fri Oct 19 17:48:08 2012 +0100
+++ b/.hgtags	Thu Oct 25 23:25:08 2012 +0100
@@ -160,3 +160,30 @@
 68da3a8292fc7e068f1ca2fd5ad95d90e2872845 lambda-b48
 92ef69a3ba61b4252c2c129bed190f3d2e91d6c9 lambda-b50
 92ef69a3ba61b4252c2c129bed190f3d2e91d6c9 lambda-b56
+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
\ No newline at end of file
--- a/make/jprt.properties	Fri Oct 19 17:48:08 2012 +0100
+++ b/make/jprt.properties	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/make/tools/anttasks/CompilePropertiesTask.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/make/tools/anttasks/CompilePropertiesTask.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2010, 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
--- a/make/tools/anttasks/GenStubsTask.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/make/tools/anttasks/GenStubsTask.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/make/tools/anttasks/SelectToolTask.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/make/tools/anttasks/SelectToolTask.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/make/tools/compileproperties/CompileProperties.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/make/tools/compileproperties/CompileProperties.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/make/tools/genstubs/GenStubs.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/make/tools/genstubs/GenStubs.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,7 @@
          */
         public void visitTopLevel(JCCompilationUnit tree) {
             super.visitTopLevel(tree);
-            tree.docComments = Collections.emptyMap();
+            tree.docComments = null;
         }
 
         /**
--- a/src/share/classes/com/sun/javadoc/Doc.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/javadoc/Doc.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 @@
 
     /**
      * Return comment as an array of tags. Includes inline tags
-     * (i.e. {&#64link <i>reference</i>} tags)  but not
+     * (i.e. {&#64;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 @@
     /**
      * 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. {&#64;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".
--- a/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/javadoc/ExecutableMemberDoc.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -90,8 +90,8 @@
     /**
      * 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>&#64;exception</code>
+     * and <code>&#64;throws</code> tags.
      */
     ThrowsTag[] throwsTags();
 
@@ -99,7 +99,7 @@
      * 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>&#64;param</code> tags
      * corresponding to the parameters of this method.
      */
     ParamTag[] paramTags();
@@ -107,7 +107,7 @@
     /**
      * 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>&#64;param</code> tags
      * corresponding to the type parameters of this method.
      * @since 1.5
      */
--- a/src/share/classes/com/sun/javadoc/Tag.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/javadoc/Tag.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -127,7 +127,7 @@
     /**
      * 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. {&#64;link <i>reference</i>} tags)  but not
      * block tags.
      * Each section of plain text is represented as a {@link Tag}
      * of kind "Text".
--- a/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/source/tree/LambdaExpressionTree.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,11 +31,11 @@
  * A tree node for a lambda expression.
  *
  * For example:
- * <pre>
+ * <pre>{@code
  *   ()->{}
  *   (List<String> ls)->ls.size()
  *   (x,y)-> { return x + y; }
- * </pre>
+ * }</pre>
  */
 public interface LambdaExpressionTree extends ExpressionTree {
 
--- a/src/share/classes/com/sun/source/tree/LineMap.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/source/tree/LineMap.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -38,8 +38,8 @@
      * @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);
 
--- a/src/share/classes/com/sun/source/util/TreeScanner.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/source/util/TreeScanner.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -52,7 +52,7 @@
  *
  * <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&lt;Integer,Void&gt; {
  *      {@literal @}Override
  *      public Integer visitIdentifier(IdentifierTree node, Void p) {
  *          return 1;
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -195,10 +195,7 @@
         ClassUseWriter clsgen;
         String path = DirectoryManager.getDirectoryPath(classdoc.
                                                             containingPackage());
-        if (path.length() > 0) {
-            path += File.separator;
-        }
-        path += "class-use";
+        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";
--- a/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ConfigurationImpl.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -227,46 +227,44 @@
             String[] os = options[oi];
             String opt = os[0].toLowerCase();
             if (opt.equals("-footer")) {
-                footer =  os[1];
-            } else  if (opt.equals("-header")) {
-                header =  os[1];
-            } else  if (opt.equals("-packagesheader")) {
-                packagesheader =  os[1];
-            } else  if (opt.equals("-doctitle")) {
-                doctitle =  os[1];
-            } else  if (opt.equals("-windowtitle")) {
-                windowtitle =  os[1];
-            } else  if (opt.equals("-top")) {
-                top =  os[1];
-            } else  if (opt.equals("-bottom")) {
-                bottom =  os[1];
-            } else  if (opt.equals("-helpfile")) {
-                helpfile =  os[1];
-            } else  if (opt.equals("-stylesheetfile")) {
-                stylesheetfile =  os[1];
-            } else  if (opt.equals("-charset")) {
-                charset =  os[1];
+                footer = os[1];
+            } else if (opt.equals("-header")) {
+                header = os[1];
+            } else if (opt.equals("-packagesheader")) {
+                packagesheader = os[1];
+            } else if (opt.equals("-doctitle")) {
+                doctitle = os[1];
+            } else if (opt.equals("-windowtitle")) {
+                windowtitle = os[1];
+            } else if (opt.equals("-top")) {
+                top = os[1];
+            } else if (opt.equals("-bottom")) {
+                bottom = os[1];
+            } else if (opt.equals("-helpfile")) {
+                helpfile = os[1];
+            } else if (opt.equals("-stylesheetfile")) {
+                stylesheetfile = os[1];
+            } else if (opt.equals("-charset")) {
+                charset = os[1];
             } else if (opt.equals("-xdocrootparent")) {
                 docrootparent = os[1];
-            } else  if (opt.equals("-nohelp")) {
+            } else if (opt.equals("-nohelp")) {
                 nohelp = true;
-            } else  if (opt.equals("-splitindex")) {
+            } else if (opt.equals("-splitindex")) {
                 splitindex = true;
-            } else  if (opt.equals("-noindex")) {
+            } else if (opt.equals("-noindex")) {
                 createindex = false;
-            } else  if (opt.equals("-use")) {
+            } else if (opt.equals("-use")) {
                 classuse = true;
-            } else  if (opt.equals("-notree")) {
+            } else if (opt.equals("-notree")) {
                 createtree = false;
-            } else  if (opt.equals("-nodeprecatedlist")) {
+            } else if (opt.equals("-nodeprecatedlist")) {
                 nodeprecatedlist = true;
-            } else  if (opt.equals("-nosince")) {
-                nosince = true;
-            } else  if (opt.equals("-nonavbar")) {
+            } else if (opt.equals("-nonavbar")) {
                 nonavbar = true;
-            } else  if (opt.equals("-nooverview")) {
+            } else if (opt.equals("-nooverview")) {
                 nooverview = true;
-            } else  if (opt.equals("-overview")) {
+            } else if (opt.equals("-overview")) {
                 overview = true;
             }
         }
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -302,7 +302,9 @@
         Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
                 getResource("doclet.Constants_Summary"));
         Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
-        Content line29 = getResource("doclet.Help_line_29");
+        Content line29 = getResource("doclet.Help_line_29",
+                getHyperLinkString("constant-values.html",
+                configuration.getText("doclet.Constants_Summary")));
         Content constPara = HtmlTree.P(line29);
         liConst.addContent(constPara);
         ul.addContent(liConst);
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -1260,7 +1260,7 @@
     /**
      * Print the Html table tag for the index summary tables. The table tag
      * printed is
-     * &lt;TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
+     * {@code <TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"> }
      */
     public void tableIndexSummary() {
         table(1, "100%", 3, 0);
@@ -1548,7 +1548,7 @@
     }
 
     /**
-     * Print the heading in Html &lt;H2> format.
+     * Print the heading in Html {@literal <H2>} format.
      *
      * @param str The Header string.
      */
@@ -2416,15 +2416,15 @@
      * <p>
      * Here is the algorithm used to fix the link:
      * <p>
-     * &lt;relative link&gt; => docRoot + &lt;relative path to file&gt; + &lt;relative link&gt;
+     * {@literal <relative link> => docRoot + <relative path to file> + <relative link> }
      * <p>
      * For example, suppose com.sun.javadoc.RootDoc has this link:
-     * &lt;a href="package-summary.html"&gt;The package Page&lt;/a&gt;
+     * {@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:
      *
-     * &lt;a href="./com/sun/javadoc/package-summary.html"&gt;The package Page&lt;/a&gt;
+     * {@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.
--- a/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Thu Oct 25 23:25:08 2012 +0100
@@ -160,7 +160,7 @@
 doclet.Help_line_26=These links show and hide the HTML frames.  All pages are available with or without frames.
 doclet.Help_line_27=The {0} link shows all classes and interfaces except non-static nested types.
 doclet.Help_line_28=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-doclet.Help_line_29=The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
+doclet.Help_line_29=The {0} page lists the static final fields and their values.
 doclet.Help_line_30=This help file applies to API documentation generated using the standard doclet.
 doclet.Help_enum_line_1=Each enum has its own separate page with the following sections:
 doclet.Help_enum_line_2=Enum declaration
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/Configuration.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -352,19 +352,21 @@
             if (opt.equals("-d")) {
                 destDirName = addTrailingFileSep(os[1]);
                 docFileDestDirName = destDirName;
-            } else  if (opt.equals("-docfilessubdirs")) {
+            } else if (opt.equals("-docfilessubdirs")) {
                 copydocfilesubdirs = true;
-            } else  if (opt.equals("-docencoding")) {
+            } else if (opt.equals("-docencoding")) {
                 docencoding = os[1];
-            } else  if (opt.equals("-encoding")) {
+            } else if (opt.equals("-encoding")) {
                 encoding = os[1];
-            } else  if (opt.equals("-author")) {
+            } else if (opt.equals("-author")) {
                 showauthor = true;
-            } else  if (opt.equals("-version")) {
+            } else if (opt.equals("-nosince")) {
+                nosince = true;
+            } else if (opt.equals("-version")) {
                 showversion = true;
-            } else  if (opt.equals("-nodeprecated")) {
+            } else if (opt.equals("-nodeprecated")) {
                 nodeprecated = true;
-            } else  if (opt.equals("-sourcepath")) {
+            } else if (opt.equals("-sourcepath")) {
                 sourcepath = os[1];
             } else if (opt.equals("-classpath") &&
                        sourcepath.length() == 0) {
@@ -388,17 +390,17 @@
                     message.warning("doclet.sourcetab_warning");
                     sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH;
                 }
-            } else  if (opt.equals("-notimestamp")) {
+            } else if (opt.equals("-notimestamp")) {
                 notimestamp = true;
-            } else  if (opt.equals("-nocomment")) {
+            } else if (opt.equals("-nocomment")) {
                 nocomment = true;
             } else if (opt.equals("-tag") || opt.equals("-taglet")) {
                 customTagStrs.add(os);
             } else if (opt.equals("-tagletpath")) {
                 tagletpath = os[1];
-            } else  if (opt.equals("-keywords")) {
+            } else if (opt.equals("-keywords")) {
                 keywords = true;
-            } else  if (opt.equals("-serialwarn")) {
+            } else if (opt.equals("-serialwarn")) {
                 serialwarn = true;
             } else if (opt.equals("-group")) {
                 group.checkPackageGroups(os[1], os[2]);
@@ -486,17 +488,18 @@
     }
 
     /**
-     * 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());
         }
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/ClassBuilder.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -125,7 +125,7 @@
     }
 
      /**
-      * Handles the &lt;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
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/taglets/TagletManager.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2008, 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
@@ -262,11 +262,7 @@
                 urls[count++] = url;
             }
         }
-        if (urls.length != count) {
-            URL[] tmp = new URL[count];
-            System.arraycopy(urls, 0, tmp, 0, count);
-            urls = tmp;
-        }
+        urls = Arrays.copyOf(urls, count);
         return urls;
     }
 
@@ -600,6 +596,7 @@
         ArrayList<Taglet> mTags = new ArrayList<Taglet>(customTags.size());
         ArrayList<Taglet> iTags = new ArrayList<Taglet>(customTags.size());
         ArrayList<Taglet> oTags = new ArrayList<Taglet>(customTags.size());
+        ArrayList<Taglet> sTags = new ArrayList<Taglet>();
         Taglet current;
         while (it.hasNext()) {
             current = it.next();
@@ -634,11 +631,12 @@
         inlineTags = iTags.toArray(new Taglet[] {});
 
         //Init the serialized form tags
-        serializedFormTags = new Taglet[4];
-        serializedFormTags[0] = customTags.get("serialData");
-        serializedFormTags[1] = customTags.get("throws");
-        serializedFormTags[2] = customTags.get("since");
-        serializedFormTags[3] = customTags.get("see");
+        sTags.add(customTags.get("serialData"));
+        sTags.add(customTags.get("throws"));
+        if (!nosince)
+            sTags.add(customTags.get("since"));
+        sTags.add(customTags.get("see"));
+        serializedFormTags = sTags.toArray(new Taglet[] {});
     }
 
     /**
--- a/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/BasicJavacTask.java	Thu Oct 25 23:25:08 2012 +0100
@@ -136,4 +136,11 @@
         throw new IllegalStateException();
     }
 
+    /**
+     * For internal use only.  This method will be
+     * removed without warning.
+     */
+    public void updateContext(Context newContext) {
+        context = newContext;
+    }
 }
--- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Thu Oct 25 23:25:08 2012 +0100
@@ -60,7 +60,7 @@
 import com.sun.tools.javac.comp.MemberEnter;
 import com.sun.tools.javac.comp.Resolve;
 import com.sun.tools.javac.model.JavacElements;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.*;
@@ -117,7 +117,7 @@
         return instance;
     }
 
-    private JavacTrees(Context context) {
+    protected JavacTrees(Context context) {
         context.put(JavacTrees.class, this);
         init(context);
     }
@@ -240,10 +240,11 @@
 
     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;
@@ -285,7 +286,7 @@
 
 
         JCCompilationUnit unit = (JCCompilationUnit) path.getCompilationUnit();
-        Copier copier = new Copier(treeMaker.forToplevel(unit));
+        Copier copier = createCopier(treeMaker.forToplevel(unit));
 
         Env<AttrContext> env = null;
         JCMethodDecl method = null;
@@ -371,10 +372,10 @@
     /**
      * Makes a copy of a tree, noting the value resulting from copying a particular leaf.
      **/
-    static class Copier extends TreeCopier<JCTree> {
+    protected static class Copier extends TreeCopier<JCTree> {
         JCTree leafCopy = null;
 
-        Copier(TreeMaker M) {
+        protected Copier(TreeMaker M) {
             super(M);
         }
 
@@ -387,6 +388,10 @@
         }
     }
 
+    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.
--- a/src/share/classes/com/sun/tools/javac/api/MultiTaskListener.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/MultiTaskListener.java	Thu Oct 25 23:25:08 2012 +0100
@@ -79,10 +79,8 @@
             if (ccw.unwrap(l) == listener)
                 throw new IllegalStateException();
         }
-        TaskListener[] newListeners = new TaskListener[listeners.length + 1];
-        System.arraycopy(listeners, 0, newListeners, 0, listeners.length);
-        newListeners[newListeners.length - 1] = ccw.wrap(listener);
-        listeners = newListeners;
+        listeners = Arrays.copyOf(listeners, listeners.length + 1);
+        listeners[listeners.length - 1] = ccw.wrap(listener);
     }
 
     public void remove(TaskListener listener) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Annotations.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,294 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 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.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;
+import com.sun.tools.javac.util.*;
+
+/**
+ * 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 have 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 sate 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> NOT_STARTED = List.of(null);
+    private static final List<Attribute.Compound> IN_PROGRESS = List.of(null);
+    /*
+     * This field should never be null
+     */
+    private List<Attribute.Compound> attributes = NOT_STARTED;
+    /*
+     * The Symbol this Annotatios belong to
+     */
+    private final Symbol s;
+
+    public Annotations(Symbol s) {
+        this.s = s;
+    }
+
+    public List<Attribute.Compound> getAttributes() {
+        return filterSentinels(attributes);
+    }
+
+    public void setAttributes(List<Attribute.Compound> a) {
+        Assert.check(pendingCompletion() || !isStarted());
+        if (a == null) {
+            throw new NullPointerException();
+        }
+        attributes = a;
+    }
+
+    public void setAttributes(Annotations other) {
+        if (other == null) {
+            throw new NullPointerException();
+        }
+        setAttributes(other.getAttributes());
+    }
+
+    public void setAttributesWithCompletion(final Annotate.AnnotateRepeatedContext ctx) {
+        Assert.check(pendingCompletion() || (!isStarted() && s.kind == PCK));
+
+        Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated = ctx.annotated;
+        boolean atLeastOneRepeated = false;
+        List<Attribute.Compound> buf = List.<Attribute.Compound>nil();
+        for (ListBuffer<Attribute.Compound> lb : annotated.values()) {
+            if (lb.size() == 1) {
+                buf = buf.prepend(lb.first());
+            } else { // repeated
+                buf = buf.prepend(new Placeholder(lb.toList(), s));
+                atLeastOneRepeated = true;
+            }
+        }
+
+        // Add non-repeating attributes
+        setAttributes(buf.reverse());
+
+        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 @ContainedBy 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 @ContainedBy
+            // 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: " + s + " in: " + s.owner;
+                }
+
+                @Override
+                public void enterAnnotation() {
+                    complete(ctx);
+                }
+            });
+        }
+    }
+
+    public Annotations reset() {
+        attributes = IN_PROGRESS;
+        return this;
+    }
+
+    public boolean isEmpty() {
+        return !isStarted()
+                || pendingCompletion()
+                || attributes.isEmpty();
+    }
+
+    public boolean pendingCompletion() {
+        return attributes == IN_PROGRESS;
+    }
+
+    public Annotations append(List<Attribute.Compound> l) {
+        attributes = filterSentinels(attributes);
+
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (attributes.isEmpty()) {
+            attributes = l;
+        } else {
+            attributes = attributes.appendList(l);
+        }
+        return this;
+    }
+
+    public Annotations prepend(List<Attribute.Compound> l) {
+        attributes = filterSentinels(attributes);
+
+        if (l.isEmpty()) {
+            ; // no-op
+        } else if (attributes.isEmpty()) {
+            attributes = l;
+        } else {
+            attributes = attributes.prependList(l);
+        }
+        return this;
+    }
+
+    private List<Attribute.Compound> filterSentinels(List<Attribute.Compound> a) {
+        return (a == IN_PROGRESS || a == NOT_STARTED)
+                ? List.<Attribute.Compound>nil()
+                : a;
+    }
+
+    private boolean isStarted() {
+        return attributes != NOT_STARTED;
+    }
+
+    private List<Attribute.Compound> getPlaceholders() {
+        List<Attribute.Compound> res = List.<Attribute.Compound>nil();
+        for (Attribute.Compound a : filterSentinels(attributes)) {
+            if (a instanceof Placeholder) {
+                res = res.prepend(a);
+            }
+        }
+        return res.reverse();
+    }
+
+    /*
+     * Replace Placeholders for repeating annotations with their containers
+     */
+    private void complete(Annotate.AnnotateRepeatedContext ctx) {
+        Assert.check(!pendingCompletion());
+        Log log = ctx.log;
+        Env<AttrContext> env = ctx.env;
+        JavaFileObject oldSource = log.useSource(env.toplevel.sourcefile);
+        try {
+
+            if (isEmpty()) {
+                return;
+            }
+
+            List<Attribute.Compound> result = List.nil();
+            for (Attribute.Compound a : getAttributes()) {
+                if (a instanceof Placeholder) {
+                    Attribute.Compound replacement = replaceOne((Placeholder) 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 Attribute.Compound replaceOne(Placeholder placeholder, Annotate.AnnotateRepeatedContext ctx) {
+        Log log = ctx.log;
+
+        // Process repeated annotations
+        Attribute.Compound validRepeated =
+                ctx.processRepeatedAnnotations(placeholder.getPlaceholderFor());
+
+        if (validRepeated != null) {
+            // Check that the container isn't manually
+            // present along with repeated instances of
+            // its contained annotation.
+            ListBuffer<Attribute.Compound> manualContainer = ctx.annotated.get(validRepeated.type.tsym);
+            if (manualContainer != null) {
+                log.error(ctx.pos.get(manualContainer.first()), "invalid.containedby.annotation.repeated.and.container.present",
+                        manualContainer.first().type.tsym);
+            }
+        }
+
+        // A null return will delete the Placeholder
+        return validRepeated;
+
+    }
+
+    private static class Placeholder extends Attribute.Compound {
+
+        private List<Attribute.Compound> placeholderFor;
+        private Symbol on;
+
+        public Placeholder(List<Attribute.Compound> placeholderFor, Symbol on) {
+            super(Type.noType, List.<Pair<Symbol.MethodSymbol, Attribute>>nil());
+            this.placeholderFor = placeholderFor;
+            this.on = on;
+        }
+
+        @Override
+        public String toString() {
+            return "<placeholder: " + placeholderFor + " on: " + on + ">";
+        }
+
+        public List<Attribute.Compound> getPlaceholderFor() {
+            return placeholderFor;
+        }
+    }
+}
--- a/src/share/classes/com/sun/tools/javac/code/Attribute.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -103,11 +103,11 @@
      *  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 +118,13 @@
                                       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);
         }
     }
 
@@ -212,6 +212,12 @@
             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();
--- a/src/share/classes/com/sun/tools/javac/code/Kinds.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Kinds.java	Thu Oct 25 23:25:08 2012 +0100
@@ -25,10 +25,10 @@
 
 package com.sun.tools.javac.code;
 
-import com.sun.source.tree.MemberReferenceTree;
 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;
 
@@ -86,12 +86,12 @@
     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+9; // missing enclosing class
+    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"),
--- a/src/share/classes/com/sun/tools/javac/code/Lint.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Lint.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -70,16 +70,16 @@
      * Returns the result of combining the values in this object with
      * the given annotations.
      */
-    public Lint augment(List<Attribute.Compound> attrs) {
-        return augmentor.augment(this, attrs);
+    public Lint augment(Annotations annots) {
+        return augmentor.augment(this, annots.getAttributes());
     }
 
     /**
      * 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);
+    public Lint augment(Annotations annots, long flags) {
+        Lint l = augmentor.augment(this, annots.getAttributes());
         if ((flags & DEPRECATED) != 0) {
             if (l == this)
                 l = new Lint(this);
--- a/src/share/classes/com/sun/tools/javac/code/Printer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Printer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -60,6 +60,8 @@
         this.raw = raw;
     }
 
+    protected Printer() { }
+
     /**
      * This method should be overriden in order to provide proper i18n support.
      *
@@ -173,40 +175,6 @@
     public String visitForAll(ForAll t, Locale locale) {
         return "<" + visitTypes(t.tvars, locale) + ">" + visit(t.qtype, locale);
     }
-    
-    public String visitDeferredType(DeferredType<?> t, Locale locale) {
-        return raw ? localize(locale, getDeferredKey(t.tree)) :
-            deferredTypeTree2String(t.tree);
-    }
-    //where
-        private String deferredTypeTree2String(JCTree tree) {
-            switch(tree.getTag()) {
-                case PARENS:
-                    return deferredTypeTree2String(((JCTree.JCParens)tree).expr);
-                case LAMBDA:
-                case REFERENCE:
-                case CONDEXPR:
-                    return Pretty.toSimpleString(tree, 5);
-                default:
-                    Assert.error("unexpected tree kind " + tree.getKind());
-                    return null;
-            }
-        }
-        private String getDeferredKey (JCTree tree) {
-            switch (tree.getTag()) {
-                case PARENS:
-                    return getDeferredKey(((JCTree.JCParens)tree).expr);
-                case LAMBDA:
-                     return "compiler.misc.type.lambda";
-                case REFERENCE:
-                     return "compiler.misc.type.mref";
-                case CONDEXPR:
-                     return "compiler.misc.type.conditional";
-                default:
-                    Assert.error("unexpected tree kind " + tree.getKind());
-                    return null;
-            }
-        }
 
     @Override
     public String visitUndetVar(UndetVar t, Locale locale) {
@@ -271,14 +239,10 @@
     }
 
     public String visitType(Type t, Locale locale) {
-        if (t.tag == DEFERRED) {
-            return visitDeferredType((DeferredType<?>)t, locale);
-        } else {
-            String s = (t.tsym == null || t.tsym.name == null)
-                    ? localize(locale, "compiler.misc.type.none")
-                    : t.tsym.name.toString();
-            return s;
-        }
+        String s = (t.tsym == null || t.tsym.name == null)
+                ? localize(locale, "compiler.misc.type.none")
+                : t.tsym.name.toString();
+        return s;
     }
 
     /**
--- a/src/share/classes/com/sun/tools/javac/code/Source.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, 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
@@ -212,6 +212,9 @@
     public boolean allowEffectivelyFinalInInnerClasses() {
         return compareTo(JDK1_8) >= 0;
     }
+    public boolean allowRepeatedAnnotations() {
+        return compareTo(JDK1_8) >= 0;
+    }
     public boolean allowBetterInference() {
         return compareTo(JDK1_8) >= 0;
     }
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Oct 25 23:25:08 2012 +0100
@@ -72,22 +72,24 @@
      */
     public long flags() { return flags_field; }
 
-    /** The attributes of this symbol.
+    /** The attributes of this symbol are contained in this
+     * Annotations. The Annotations instance is NOT immutable.
      */
-    public List<Attribute.Compound> attributes_field;
+    public final Annotations annotations = new Annotations(this);
 
     /** 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);
+        return Assert.checkNonNull(annotations.getAttributes());
     }
 
     /** Fetch a particular annotation from a symbol. */
     public Attribute.Compound attribute(Symbol anno) {
-        for (Attribute.Compound a : getAnnotationMirrors())
+        for (Attribute.Compound a : getAnnotationMirrors()) {
             if (a.type.tsym == anno) return a;
+        }
         return null;
     }
 
@@ -120,7 +122,6 @@
         this.owner = owner;
         this.completer = null;
         this.erasure_field = null;
-        this.attributes_field = List.nil();
         this.name = name;
     }
 
@@ -662,10 +663,11 @@
             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;
+                if (annotations.isEmpty()) {
+                    annotations.setAttributes(package_info.annotations);
             }
-            return Assert.checkNonNull(attributes_field);
+            }
+            return Assert.checkNonNull(annotations.getAttributes());
         }
 
         /** A package "exists" if a type or package that exists has
@@ -767,7 +769,7 @@
 
         public List<Attribute.Compound> getAnnotationMirrors() {
             if (completer != null) complete();
-            return Assert.checkNonNull(attributes_field);
+            return Assert.checkNonNull(annotations.getAttributes());
         }
 
         public Type erasure(Types types) {
@@ -921,7 +923,12 @@
         /** Clone this symbol with new owner.
          */
         public VarSymbol clone(Symbol newOwner) {
-            VarSymbol v = new VarSymbol(flags_field, name, type, newOwner);
+            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;
@@ -1048,7 +1055,12 @@
         /** Clone this symbol with new owner.
          */
         public MethodSymbol clone(Symbol newOwner) {
-            MethodSymbol m = new MethodSymbol(flags_field, name, type, newOwner);
+            MethodSymbol m = new MethodSymbol(flags_field, name, type, newOwner) {
+                @Override
+                public Symbol baseSymbol() {
+                    return MethodSymbol.this;
+                }
+            };
             m.code = code;
             return m;
         }
--- a/src/share/classes/com/sun/tools/javac/code/Symtab.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Oct 25 23:25:08 2012 +0100
@@ -126,11 +126,9 @@
     public final Type cloneableType;
     public final Type serializableType;
     public final Type methodHandleType;
-    public final Type nativeHeaderType;
+    public final Type methodHandleLookupType;
     public final Type methodTypeType;
-    public final Type methodHandleLookupType;
-    public final Type methodHandlesType;
-    public final Type methodHandleProxies;
+    public final Type nativeHeaderType;
     public final Type throwableType;
     public final Type errorType;
     public final Type interruptedExceptionType;
@@ -161,6 +159,10 @@
     public final Type autoCloseableType;
     public final Type trustMeType;
     public final Type lambdaMetafactory;
+	public final Type containedByType;
+    public final Type containerForType;
+    public final Type documentedType;
+    public final Type elementTypeType;
 
     /** The symbol representing the length field of an array.
      */
@@ -183,6 +185,10 @@
      */
     public final Name[] boxedName = new Name[TypeTags.TypeTagCount];
 
+    /** 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.
      *  It should be updated from the outside to reflect classes defined
@@ -244,7 +250,7 @@
                             int opcode) {
         predefClass.members().enter(
             new OperatorSymbol(
-                names.fromString(name),
+                makeOperatorName(name),
                 new MethodType(List.of(left, right), res,
                                List.<Type>nil(), methodClass),
                 opcode,
@@ -252,7 +258,8 @@
     }
 
     /** 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.
      */
@@ -274,7 +281,7 @@
                                      Type res,
                                      int opcode) {
         OperatorSymbol sym =
-            new OperatorSymbol(names.fromString(name),
+            new OperatorSymbol(makeOperatorName(name),
                                new MethodType(List.of(arg),
                                               res,
                                               List.<Type>nil(),
@@ -285,6 +292,16 @@
         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.
      */
@@ -292,16 +309,7 @@
         return reader.enterClass(names.fromString(s)).type;
     }
 
-    private Type enter292Class(String s) {
-        try {
-            return enterClass("java.dyn." + s);
-        } catch (CompletionFailure cf) {
-            return enterClass("java.lang.invoke." + s);
-        }
-    }
-
-
-    public void synthesizeEmptyTypeIfMissing(final Type type, final long flags) {
+    public void synthesizeEmptyInterfaceIfMissing(final Type type) {
         final Completer completer = type.tsym.completer;
         if (completer != null) {
             type.tsym.completer = new Completer() {
@@ -309,7 +317,7 @@
                     try {
                         completer.complete(sym);
                     } catch (CompletionFailure e) {
-                        sym.flags_field |= flags;
+                        sym.flags_field |= (PUBLIC | INTERFACE);
                         ((ClassType) sym.type).supertype_field = objectType;
                     }
                 }
@@ -449,10 +457,8 @@
         throwableType = enterClass("java.lang.Throwable");
         serializableType = enterClass("java.io.Serializable");
         methodHandleType = enterClass("java.lang.invoke.MethodHandle");
+        methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
         methodTypeType = enterClass("java.lang.invoke.MethodType");
-        methodHandlesType = enterClass("java.lang.invoke.MethodHandles");
-        methodHandleLookupType = enterClass("java.lang.invoke.MethodHandles$Lookup");
-        methodHandleProxies = enterClass("java.lang.invoke.MethodHandleProxies");
         errorType = enterClass("java.lang.Error");
         illegalArgumentExceptionType = enterClass("java.lang.IllegalArgumentException");
         interruptedExceptionType = enterClass("java.lang.InterruptedException");
@@ -486,6 +492,10 @@
         deprecatedType = enterClass("java.lang.Deprecated");
         suppressWarningsType = enterClass("java.lang.SuppressWarnings");
         inheritedType = enterClass("java.lang.annotation.Inherited");
+        containedByType = enterClass("java.lang.annotation.ContainedBy");
+        containerForType = enterClass("java.lang.annotation.ContainerFor");
+        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,
@@ -497,10 +507,10 @@
 		nativeHeaderType = enterClass("javax.tools.annotation.GenerateNativeHeader");
         lambdaMetafactory = enterClass("java.lang.invoke.LambdaMetafactory");
 
-        synthesizeEmptyTypeIfMissing(autoCloseableType, PUBLIC | INTERFACE);
-        synthesizeEmptyTypeIfMissing(cloneableType, PUBLIC | INTERFACE);
-        synthesizeEmptyTypeIfMissing(serializableType, PUBLIC | INTERFACE);
-        synthesizeEmptyTypeIfMissing(lambdaMetafactory, PUBLIC);
+        synthesizeEmptyInterfaceIfMissing(autoCloseableType);
+        synthesizeEmptyInterfaceIfMissing(cloneableType);
+        synthesizeEmptyInterfaceIfMissing(serializableType);
+        synthesizeEmptyInterfaceIfMissing(lambdaMetafactory);
         synthesizeBoxTypeIfMissing(doubleType);
         synthesizeBoxTypeIfMissing(floatType);
         synthesizeBoxTypeIfMissing(voidType);
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -27,8 +27,8 @@
 
 import java.util.Collections;
 
+import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.code.Symbol.*;
 
 import java.util.EnumMap;
 import java.util.EnumSet;
@@ -37,9 +37,9 @@
 
 import javax.lang.model.type.*;
 
+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.*;
 
 /** This class represents Java types. The class itself defines the behavior of
@@ -59,7 +59,7 @@
  *  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>
  *
@@ -74,11 +74,8 @@
 
     /** Constant type: no type at all. */
     public static final JCNoType noType = new JCNoType(NONE);
-    
-    /** Constant type: proto type of all poly types. */
-    public static final JCNoType anyPoly = new JCNoType(NONE);
-    
-    /** Constant type: special type for recovery deferred attribution. */
+
+    /** Constant type: special type to be used during recovery of deferred expressions. */
     public static final JCNoType recoveryType = new JCNoType(NONE);
 
     /** If this switch is turned on, the names of type variables
@@ -404,7 +401,7 @@
     public boolean isExtendsBound() { return false; }
     public boolean isUnbound() { return false; }
     public Type withTypeVar(Type t) { return this; }
-    
+
     /** The underlying method type of this type.
      */
     public MethodType asMethodType() { throw new AssertionError(); }
@@ -703,7 +700,7 @@
         /** 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
@@ -1180,111 +1177,116 @@
     }
 
     /** 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 {
-         
-         /** 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 */
-         private Map<InferenceBound, List<Type>> bounds;
-         
-         /** inference variable's inferred type (set from Infer.java) */
-         public Type inst = null;
-         
-         /** 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(TypeVar origin, boolean includeBounds, Types types) {
-             super(UNDETVAR, origin);
-             bounds = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class);
-             bounds.put(InferenceBound.UPPER, includeBounds ? types.getBounds(origin) : List.<Type>nil());
-             bounds.put(InferenceBound.LOWER, List.<Type>nil());
-             bounds.put(InferenceBound.EQ, List.<Type>nil());
-         }
- 
-         public String toString() {
-             if (inst != null) return inst.toString();
-             else return qtype + "?";
-         }
- 
-         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) {
+     *  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 {
+
+        /** 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 */
+        private Map<InferenceBound, List<Type>> bounds;
+
+        /** inference variable's inferred type (set from Infer.java) */
+        public Type inst = null;
+
+        /** 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(TypeVar origin, Types types) {
+            this(origin, types, true);
+        }
+
+        public UndetVar(TypeVar origin, Types types, boolean includeBounds) {
+            super(UNDETVAR, origin);
+            bounds = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class);
+            bounds.put(InferenceBound.UPPER, includeBounds ? types.getBounds(origin) : List.<Type>nil());
+            bounds.put(InferenceBound.LOWER, List.<Type>nil());
+            bounds.put(InferenceBound.EQ, List.<Type>nil());
+        }
+
+        public String toString() {
+            if (inst != null) return inst.toString();
+            else return qtype + "?";
+        }
+
+        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();
-         }
-         
-         /** add a bound of a given kind - this might trigger listener notification */
-         public void addBound(InferenceBound ib, Type bound, Types types) {
-             List<Type> prevBounds = bounds.get(ib);
-             for (Type b : prevBounds) {
-                 if (types.isSameType(b, bound))
-                     return;
-             }
-             bounds.put(ib, prevBounds.prepend(bound));
-             notifyChange(EnumSet.of(ib));
-         }
-         
-         /** replace types in all bounds - this might trigger listener notification */
-         public void substBounds(List<Type> from, List<Type> to, Types types) {
-             EnumSet<InferenceBound> changed = EnumSet.noneOf(InferenceBound.class);
-             Map<InferenceBound, List<Type>> bounds2 = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class);
-             for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
-                 InferenceBound ib = _entry.getKey();
-                 List<Type> prevBounds = _entry.getValue();
-                 List<Type> newBounds = types.subst(prevBounds, from, to);
-                 bounds2.put(ib, newBounds);
-                 if (prevBounds != newBounds) {
-                     changed.add(ib);
-                 }
-             }
-             if (!changed.isEmpty()) {
-                 bounds = bounds2;
-                 notifyChange(changed);
-             }
-         }
-         
-         private void notifyChange(EnumSet<InferenceBound> ibs) {
-             if (listener != null) {
-                 listener.varChanged(this, ibs);
-             }
-         }
-     }
+            }
+            return buf.toList();
+        }
+
+        /** add a bound of a given kind - this might trigger listener notification */
+        public void addBound(InferenceBound ib, Type bound, Types types) {
+            List<Type> prevBounds = bounds.get(ib);
+            for (Type b : prevBounds) {
+                if (types.isSameType(b, bound)) {
+                    return;
+                }
+            }
+            bounds.put(ib, prevBounds.prepend(bound));
+            notifyChange(EnumSet.of(ib));
+        }
+
+        /** replace types in all bounds - this might trigger listener notification */
+        public void substBounds(List<Type> from, List<Type> to, Types types) {
+            EnumSet<InferenceBound> changed = EnumSet.noneOf(InferenceBound.class);
+            Map<InferenceBound, List<Type>> bounds2 = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class);
+            for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) {
+                InferenceBound ib = _entry.getKey();
+                List<Type> prevBounds = _entry.getValue();
+                List<Type> newBounds = types.subst(prevBounds, from, to);
+                bounds2.put(ib, newBounds);
+                if (prevBounds != newBounds) {
+                    changed.add(ib);
+                }
+            }
+            if (!changed.isEmpty()) {
+                bounds = bounds2;
+                notifyChange(changed);
+            }
+        }
+
+        private void notifyChange(EnumSet<InferenceBound> ibs) {
+            if (listener != null) {
+                listener.varChanged(this, ibs);
+            }
+        }
+    }
 
     /** Represents VOID or NONE.
      */
--- a/src/share/classes/com/sun/tools/javac/code/TypeTags.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/TypeTags.java	Thu Oct 25 23:25:08 2012 +0100
@@ -101,18 +101,14 @@
     /** The tag of all polymorphic (method-) types.
      */
     public static final int FORALL = WILDCARD+1;
-    
+
     /** The tag of deferred expression types in method context
      */
     public static final int DEFERRED = FORALL+1;
-    
-    /** The tag of a recovery type (used for recovering deferred types)
-     */
-    public static final int RECOVERY = DEFERRED+1;
 
     /** The tag of the bottom type <null>.
      */
-    public static final int BOT = RECOVERY+1;
+    public static final int BOT = DEFERRED+1;
 
     /** The tag of a missing type.
      */
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Oct 25 23:25:08 2012 +0100
@@ -34,10 +34,10 @@
 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.Scope.CompoundScope;
 import com.sun.tools.javac.code.Type.UndetVar.InferenceBound;
 import com.sun.tools.javac.comp.Check;
 
+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.*;
@@ -80,9 +80,10 @@
     final boolean allowDefenderMethods;
     final ClassReader reader;
     final Check chk;
+    JCDiagnostic.Factory diags;
     List<Warner> warnStack = List.nil();
     final Name capturedName;
-    private final SAMConversionFailure samConversionFailure;
+    private final FunctionDescriptorLookupError functionDescriptorLookupError;
 
     // <editor-fold defaultstate="collapsed" desc="Instantiating">
     public static Types instance(Context context) {
@@ -105,9 +106,8 @@
         chk = Check.instance(context);
         capturedName = names.fromString("<captured wildcard>");
         messages = JavacMessages.instance(context);
-        Options opts = Options.instance(context);
-        JCDiagnostic.Factory diags = JCDiagnostic.Factory.instance(context);
-        samConversionFailure = new SAMConversionFailure(diags);
+        diags = JCDiagnostic.Factory.instance(context);
+        functionDescriptorLookupError = new FunctionDescriptorLookupError();
     }
     // </editor-fold>
 
@@ -304,29 +304,21 @@
 
     // <editor-fold defaultstate="collapsed" desc="findSam">
 
-    public static class SAMConversionFailure extends RuntimeException {
+    /**
+     * 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;
-        JCDiagnostic.Factory diags;
-
-        SAMConversionFailure(JCDiagnostic.Factory diags) {
+
+        FunctionDescriptorLookupError() {
             this.diagnostic = null;
-            this.diags = diags;
-        }
-        SAMConversionFailure setMessage() {
-            this.diagnostic = null;
-            return this;
         }
-        SAMConversionFailure setMessage(String key) {
-            this.diagnostic = key != null ? diags.fragment(key) : null;
-            return this;
-        }
-        SAMConversionFailure setMessage(String key, Object... args) {
-            this.diagnostic = key != null ? diags.fragment(key, args) : null;
-            return this;
-        }
-        SAMConversionFailure setMessage(JCDiagnostic diag) {
+
+        FunctionDescriptorLookupError setMessage(JCDiagnostic diag) {
             this.diagnostic = diag;
             return this;
         }
@@ -335,32 +327,36 @@
             return diagnostic;
         }
     }
-    
-    private class FunctionalDescriptorResult {
-        Symbol descSym;
-
-        FunctionalDescriptorResult(Symbol descSym) {
-            this.descSym = descSym;
-        }
-
-        public Symbol getSymbol() {
-            return descSym;
-        }
-
-        public Type getType(Type origin) {
-            return memberType(origin, descSym);
-        }
-    }
-
+
+    /**
+     * 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 origin) {
+                return memberType(origin, descSym);
+            }
+        }
+
         class Entry {
-            final FunctionalDescriptorResult cachedDescRes;
+            final FunctionDescriptor cachedDescRes;
             final int prevMark;
 
-            public Entry(FunctionalDescriptorResult cachedDescRes,
+            public Entry(FunctionDescriptor cachedDescRes,
                     int prevMark) {
                 this.cachedDescRes = cachedDescRes;
                 this.prevMark = prevMark;
@@ -371,12 +367,12 @@
             }
         }
 
-        FunctionalDescriptorResult get(TypeSymbol origin) throws SAMConversionFailure {
+        FunctionDescriptor get(TypeSymbol origin) throws FunctionDescriptorLookupError {
             Entry e = _map.get(origin);
             CompoundScope members = membersClosure(origin.type, false);
             if (e == null ||
                     !e.matches(members.getMark())) {
-                FunctionalDescriptorResult descRes = findDescriptorInternal(origin, members);
+                FunctionDescriptor descRes = findDescriptorInternal(origin, members);
                 _map.put(origin, new Entry(descRes, members.getMark()));
                 return descRes;
             }
@@ -385,6 +381,11 @@
             }
         }
 
+        /**
+         * Scope filter used to skip methods that should be ignored during
+         * function interface conversion (such as methods overridden by
+         * j.l.Object)
+         */
         class DescriptorFilter implements Filter<Symbol> {
 
             TypeSymbol origin;
@@ -407,10 +408,13 @@
             }
         };
 
-        public FunctionalDescriptorResult findDescriptorInternal(TypeSymbol origin, CompoundScope membersCache) throws SAMConversionFailure {
+        /**
+         * Compute the function descriptor associated with a given functional interface
+         */
+        public FunctionDescriptor findDescriptorInternal(TypeSymbol origin, CompoundScope membersCache) throws FunctionDescriptorLookupError {
             if (!origin.isInterface()) {
-                //t must be an abstract class or an interface
-                throw samConversionFailure.setMessage("target.for.lambda.conv.must.be.interface");
+                //t must be an interface
+                throw failure("not.a.functional.intf");
             }
 
             final ListBuffer<Symbol> abstracts = ListBuffer.lb();
@@ -422,48 +426,62 @@
                     abstracts.append(sym);
                 } else {
                     //the target method(s) should be the only abstract members of t
-                    throw samConversionFailure.setMessage("incompatible.targets.for.lambda.conv", Kinds.kindName(origin), origin);
+                    throw failure("not.a.functional.intf.1",
+                            diags.fragment("incompatible.abstracts", Kinds.kindName(origin), origin));
                 }
             }
             if (abstracts.isEmpty()) {
                 //t must define a suitable non-generic method
-                throw samConversionFailure.setMessage("no.target.method.for.lambda.conv", Kinds.kindName(origin), origin);
+                throw failure("not.a.functional.intf.1",
+                            diags.fragment("no.abstracts", Kinds.kindName(origin), origin));
             } else if (abstracts.size() == 1) {
                 if (abstracts.first().type.tag == FORALL) {
-                    throw samConversionFailure.setMessage("invalid.generic.target.for.lambda.conv",
-                                                          abstracts.first(),
-                                                          Kinds.kindName(origin),
-                                                          origin);
+                    throw failure("invalid.generic.desc.in.functional.intf",
+                            abstracts.first(),
+                            Kinds.kindName(origin),
+                            origin);
                 } else {
-                    return new FunctionalDescriptorResult(abstracts.first());
+                    return new FunctionDescriptor(abstracts.first());
                 }
             } else { // size > 1
                 for (Symbol msym : abstracts) {
                     if (msym.type.tag == FORALL) {
-                        throw samConversionFailure.setMessage("invalid.generic.target.for.lambda.conv",
-                                                              abstracts.first(),
-                                                              Kinds.kindName(origin),
-                                                              origin);
+                        throw failure("invalid.generic.desc.in.functional.intf",
+                                abstracts.first(),
+                                Kinds.kindName(origin),
+                                origin);
                     }
                 }
-                FunctionalDescriptorResult descRes = mergeDescriptors(origin, abstracts.toList());
+                FunctionDescriptor descRes = mergeDescriptors(origin, abstracts.toList());
                 if (descRes == null) {
-                    //we can get here if the SAM class is ill-formed
-                    throw samConversionFailure.setMessage("incompatible.targets.for.lambda.conv", Kinds.kindName(origin), origin);
+                    //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 SAM descriptor given a list
-         * of override-equivalent methods in the SAM type. The resulting method
-         * type is a method type that is override-equivalent and return-type
-         * substitutable with each method in the original list.
+         * 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 FunctionalDescriptorResult mergeDescriptors(TypeSymbol origin, List<Symbol> methodSyms) {
-            //merge argument types - simply take the signature that is a
-            //subsigature of all other signatures in the list (as per JLS 8.4.2)
+        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);
@@ -476,13 +494,13 @@
                 mostSpecific = mostSpecific.prepend(msym1);
             }
             if (mostSpecific.isEmpty()) {
-                return null;//argtypes = erasure(memberType(origin.type, methodSyms.head)).getParameterTypes();
+                return null;
             }
 
 
-            //merge return types - this is done in two phases: (i) first, the most
-            //specific return type using return type substitutability (as defined in JLS 8.4.5);
-            //(ii) if this fails, a second attempt is made using unchecked subtyping
+            //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) {
@@ -506,7 +524,7 @@
             }
             if (bestSoFar == null) return null;
 
-            //merge thrown types - form the union of all the thrown types in
+            //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) {
@@ -515,9 +533,9 @@
                     mt1.getThrownTypes() :
                     chk.intersect(mt1.getThrownTypes(), thrown);
             }
-            
+
             final List<Type> thrown1 = thrown;
-            return new FunctionalDescriptorResult(bestSoFar) {
+            return new FunctionDescriptor(bestSoFar) {
                 @Override
                 public Type getType(Type origin) {
                     Type mt = memberType(origin, getSymbol());
@@ -531,6 +549,14 @@
                     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();
@@ -539,23 +565,26 @@
      * 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 SAMConversionFailure {
+    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 SAMConversionFailure {
+    public Type findDescriptorType(Type origin) throws FunctionDescriptorLookupError {
         return descCache.get(origin.tsym).getType(origin);
     }
 
-    public boolean isSam(TypeSymbol tsym) {
+    /**
+     * Is given type a functional interface?
+     */
+    public boolean isFunctionalInterface(TypeSymbol tsym) {
         try {
             findDescriptorSymbol(tsym);
             return true;
-        } catch (SAMConversionFailure ex) {
+        } catch (FunctionDescriptorLookupError ex) {
             return false;
         }
     }
@@ -1580,6 +1609,8 @@
             return elemtype(upperBound(t));
         case ARRAY:
             return ((ArrayType)t).elemtype;
+        case FORALL:
+            return elemtype(((ForAll)t).qtype);
         case ERROR:
             return t;
         default:
@@ -1612,6 +1643,20 @@
         }
         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.tag == VOID ||
+            t.tag >= PACKAGE) {
+            Assert.error("Type t must not be a a VOID or PACKAGE type, " + t.toString());
+        }
+        return new ArrayType(t, syms.arrayClass);
+    }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="asSuper">
@@ -1843,9 +1888,16 @@
      * type parameters in t are deleted.
      */
     public Type erasure(Type t) {
-        return erasure(t, false);
+        return eraseNotNeeded(t)? t : erasure(t, false);
     }
     //where
+    private boolean eraseNotNeeded(Type t) {
+        // 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.tag <= lastBaseTag) || (syms.stringType.tsym == t.tsym);
+    }
+
     private Type erasure(Type t, boolean recurse) {
         if (t.tag <= lastBaseTag)
             return t; /* fast special case */
@@ -2253,7 +2305,7 @@
         return hasSameArgs(t, s) ||
             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)) {
@@ -3472,6 +3524,14 @@
         }
         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.tag == NONE ? t : unboxedType;
+    }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="Capture conversion">
@@ -4131,8 +4191,12 @@
     // <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) {
--- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,10 @@
 
 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.*;
@@ -83,8 +86,9 @@
     private int enterCount = 0;
 
     ListBuffer<Annotator> q = new ListBuffer<Annotator>();
+    ListBuffer<Annotator> repeatedQ = new ListBuffer<Annotator>();
 
-    public void later(Annotator a) {
+    public void normal(Annotator a) {
         q.append(a);
     }
 
@@ -92,6 +96,10 @@
         q.prepend(a);
     }
 
+    public void repeated(Annotator a) {
+        repeatedQ.append(a);
+    }
+
     /** Called when the Enter phase starts. */
     public void enterStart() {
         enterCount++;
@@ -109,6 +117,10 @@
         try {
             while (q.nonEmpty())
                 q.next().enterAnnotation();
+
+            while (repeatedQ.nonEmpty()) {
+                repeatedQ.next().enterAnnotation();
+            }
         } finally {
             enterCount--;
         }
@@ -124,6 +136,53 @@
         String toString();
     }
 
+    /**
+     * This context contains all the information needed to synthesize new
+     * annotations trees by the completer for repeating annotations.
+     */
+    public class AnnotateRepeatedContext {
+        public final Env<AttrContext> env;
+        public final Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated;
+        public final Map<Attribute.Compound, JCDiagnostic.DiagnosticPosition> pos;
+        public final Log log;
+
+        public AnnotateRepeatedContext(Env<AttrContext> env,
+                                       Map<Symbol.TypeSymbol, ListBuffer<Attribute.Compound>> annotated,
+                                       Map<Attribute.Compound, JCDiagnostic.DiagnosticPosition> pos,
+                                       Log log) {
+            Assert.checkNonNull(env);
+            Assert.checkNonNull(annotated);
+            Assert.checkNonNull(pos);
+            Assert.checkNonNull(log);
+
+            this.env = env;
+            this.annotated = annotated;
+            this.pos = pos;
+            this.log = log;
+        }
+
+        /**
+         * 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 Attribute.Compound processRepeatedAnnotations(List<Attribute.Compound> repeatingAnnotations) {
+            return Annotate.this.processRepeatedAnnotations(repeatingAnnotations, this);
+        }
+
+        /**
+         * 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.
@@ -268,4 +327,203 @@
             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 Attribute.Compound processRepeatedAnnotations(List<Attribute.Compound> annotations,
+            AnnotateRepeatedContext ctx) {
+        Attribute.Compound firstOccurrence = annotations.head;
+        List<Attribute> repeated = List.nil();
+        Type origAnnoType;
+        Type arrayOfOrigAnnoType = null;
+        Type targetContainerType = null;
+        MethodSymbol containerValueSymbol = null;
+
+        Assert.check(!annotations.isEmpty() &&
+                     !annotations.tail.isEmpty()); // i.e. size() > 1
+
+        for (List<Attribute.Compound> al = annotations;
+             !al.isEmpty();
+             al = al.tail)
+        {
+            Attribute.Compound currentAnno = al.head;
+
+            origAnnoType = currentAnno.type;
+            if (arrayOfOrigAnnoType == null) {
+                arrayOfOrigAnnoType = types.makeArrayType(origAnnoType);
 }
+
+            Type currentContainerType = getContainingType(currentAnno, ctx.pos.get(currentAnno));
+            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();
+            JCAnnotation annoTree;
+            TreeMaker m = make.at(ctx.pos.get(firstOccurrence));
+            Pair<MethodSymbol, Attribute> p =
+                    new Pair<MethodSymbol, Attribute>(containerValueSymbol,
+                                                      new Attribute.Array(arrayOfOrigAnnoType, repeated));
+            annoTree = m.Annotation(new Attribute.Compound(targetContainerType,
+                    List.of(p)));
+            Attribute.Compound c = enterAnnotation(annoTree,
+                                                   targetContainerType,
+                                                   ctx.env);
+            return c;
+        } 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)
+    {
+        Type origAnnoType = currentAnno.type;
+        TypeSymbol origAnnoDecl = origAnnoType.tsym;
+
+        // Fetch the ContainedBy annotation from the current
+        // annotation's declaration, or null if it has none
+        Attribute.Compound ca = origAnnoDecl.attribute(syms.containedByType.tsym);
+        if (ca == null) { // has no ContainedBy annotation
+            log.error(pos, "duplicate.annotation.missing.container", origAnnoType);
+            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 ContainedBy annotation
+        // on the declaration of the annotation type that is repeating is
+        // valid.
+
+        // ContainedBy must have at least one element
+        if (ca.values.isEmpty()) {
+            log.error(pos, "invalid.containedby.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.containedby.annotation", annoDecl);
+            return null;
+        }
+        if (!(p.snd instanceof Attribute.Class)) { // check that the value of "value" is an Attribute.Class
+            log.error(pos, "invalid.containedby.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.containedby.annotation.multiple.values",
+                      targetContainerType,
+                      nr_value_elems);
+            return null;
+        } else if (nr_value_elems == 0) {
+            log.error(pos,
+                      "invalid.containedby.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.containedby.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.containedby.annotation.value.return",
+                      targetContainerType,
+                      valueRetType,
+                      expectedType);
+            fatalError = true;
+        }
+        if (error) {
+            fatalError = true;
+        }
+
+        // Explicitly no check for/validity of @ContainerFor. That is
+        // done on declaration of the container, and at reflect time.
+
+        // The rest of the conditions for a valid containing annotation are made
+        // in Check.validateRepeatedAnnotaton();
+
+        return fatalError ? null : containerValueSymbol;
+    }
+}
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Oct 25 23:25:08 2012 +0100
@@ -25,12 +25,8 @@
 
 package com.sun.tools.javac.comp;
 
-import java.util.*;
-import java.util.Set;
-import javax.lang.model.element.ElementKind;
-import javax.tools.JavaFileObject;
-
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
 import com.sun.tools.javac.comp.Infer.InferenceContext;
 import com.sun.tools.javac.comp.Infer.InferenceContext.FreeTypeListener;
 import com.sun.tools.javac.jvm.*;
@@ -43,17 +39,20 @@
 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.tree.JCTree.JCMemberReference.ReferenceKind;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.comp.Check.CheckContext;
 
 import com.sun.source.tree.IdentifierTree;
-import com.sun.source.tree.LambdaExpressionTree;
 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 java.util.*;
+import java.util.Set;
+import javax.lang.model.element.ElementKind;
+import javax.tools.JavaFileObject;
+
 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;
@@ -61,7 +60,6 @@
 import static com.sun.tools.javac.code.Kinds.ERRONEOUS;
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.code.TypeTags.WILDCARD;
-import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** This is the main context-dependent analysis phase in GJC. It
@@ -86,12 +84,12 @@
     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;
-    final DeferredAttr deferredAttr;
     final Enter enter;
     final Target target;
     final Types types;
@@ -114,12 +112,12 @@
         syms = Symtab.instance(context);
         rs = Resolve.instance(context);
         chk = Check.instance(context);
-        deferredAttr = DeferredAttr.instance(context);
         flow = Flow.instance(context);
         memberEnter = MemberEnter.instance(context);
         make = TreeMaker.instance(context);
         enter = Enter.instance(context);
         infer = InferFactory.instance(context).getInfer();
+        deferredAttr = DeferredAttr.instance(context);
         cfolder = ConstFold.instance(context);
         target = Target.instance(context);
         types = Types.instance(context);
@@ -147,42 +145,19 @@
         findDiamonds = options.get("findDiamond") != null &&
                  source.allowDiamond();
         useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
-        identifyLambdaCandidate = options.isSet("identifyLambdaCandidate") &&
-                options.get("identifyLambdaCandidate").equals("true") ; //default disabled
+        identifyLambdaCandidate = options.getBoolean("identifyLambdaCandidate", false);
 
         statInfo = new ResultInfo(NIL, Type.noType);
         varInfo = new ResultInfo(VAR, Type.noType);
         unknownExprInfo = new ResultInfo(VAL, Type.noType);
         unknownTypeInfo = new ResultInfo(TYP, Type.noType);
-        silentRecoveryInfo = makeRecoveryInfo(true);
-        recoveryInfo = makeRecoveryInfo(false);
+        recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext);
     }
-    //where
-        private final ResultInfo makeRecoveryInfo(final boolean silent) {
-            Check.CheckContext recoveryContext = new Check.NestedCheckContext(chk.basicHandler) {
-                @Override
-                public boolean compatible(Type found, Type req, Warner warn) {
-                    return true;
-                }
-                @Override
-                public void report(DiagnosticPosition pos, JCDiagnostic details) {
-                    if (!silent) {
-                        chk.basicHandler.report(pos, details);
-                    }
-                }
-            };
-            return new ResultInfo(Kinds.VAL, Type.recoveryType, recoveryContext) {
-                @Override
-                protected Type check(DiagnosticPosition pos, Type found) {
-                    return chk.checkNonVoid(pos, super.check(pos, found));
-                }
-            };
-        }
 
     /** Switch: relax some constraints for retrofit mode.
      */
     boolean relax;
-    
+
     /** Switch: support target-typing inference
      */
     boolean allowPoly;
@@ -231,6 +206,11 @@
     boolean findDiamonds;
 
     /**
+     * Internally enables/disables diamond finder feature
+     */
+    static final boolean allowDiamondFinder = true;
+
+    /**
      * Switch: warn about use of variable before declaration?
      * RFE: 6425594
      */
@@ -265,7 +245,7 @@
      *  @param resultInfo  The expected result of the tree
      */
     Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) {
-        InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();        
+        InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext();
         Type owntype = found;
         if (owntype.tag != ERROR && resultInfo.pt.tag != METHOD && resultInfo.pt.tag != FORALL) {
             if (inferenceContext.free(found)) {
@@ -286,7 +266,7 @@
                             kindNames(resultInfo.pkind),
                             kindName(ownkind));
                     owntype = types.createErrorType(owntype);
-                }                
+                }
             }
         }
         tree.type = owntype;
@@ -313,7 +293,7 @@
              &&
              ((v.flags() & STATIC) != 0) == Resolve.isStatic(env));
     }
-    
+
     /**
      * Return the innermost enclosing owner symbol in a given attribution context
      */
@@ -335,7 +315,7 @@
                     return ((JCClassDecl)env.tree).sym;
                 case LAMBDA:
                     //a lambda is an owner - return a fresh synthetic method symbol
-                    return new MethodSymbol(0, names.lambda, null, syms.methodClass);
+                    return new MethodSymbol(0, names.empty, null, syms.methodClass);
                 case BLOCK:
                     //static/instance init blocks are owner
                     Symbol blockSym = env.info.scope.owner;
@@ -347,7 +327,7 @@
                     //toplevel is always an owner (for pkge decls)
                     return env.info.scope.owner;
             }
-            Assert.check(env.next != null);
+            Assert.checkNonNull(env.next);
             env = env.next;
         }
     }
@@ -505,7 +485,7 @@
         private BreakAttr(Env<AttrContext> env) {
             this.env = copyEnv(env);
         }
-        
+
         private Env<AttrContext> copyEnv(Env<AttrContext> env) {
             Env<AttrContext> newEnv =
                     env.dup(env.tree, env.info.dup(copyScope(env.info.scope)));
@@ -514,7 +494,7 @@
             }
             return newEnv;
         }
-        
+
         private Scope copyScope(Scope sc) {
             Scope newScope = new Scope(sc.owner);
             List<Symbol> elemsList = List.nil();
@@ -536,7 +516,7 @@
         final Type pt;
         final CheckContext checkContext;
 
-        ResultInfo(int pkind, Type pt) {            
+        ResultInfo(int pkind, Type pt) {
             this(pkind, pt, chk.basicHandler);
         }
 
@@ -549,17 +529,45 @@
         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) {
+            super(Kinds.VAL, Type.recoveryType, 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);
+                }
+            });
+        }
+
+        @Override
+        protected Type check(DiagnosticPosition pos, Type found) {
+            return chk.checkNonVoid(pos, super.check(pos, found));
+        }
     }
 
     final ResultInfo statInfo;
     final ResultInfo varInfo;
     final ResultInfo unknownExprInfo;
     final ResultInfo unknownTypeInfo;
-    final ResultInfo silentRecoveryInfo;
     final ResultInfo recoveryInfo;
 
     Type pt() {
@@ -666,14 +674,14 @@
     List<Type> attribArgs(List<JCExpression> trees, Env<AttrContext> env) {
         ListBuffer<Type> argtypes = new ListBuffer<Type>();
         for (JCExpression arg : trees) {
-            Type argtype = allowPoly && TreeInfo.isPoly(arg) ?
-                    deferredAttr.new DeferredType<JCExpression>(arg, env) :
-                    attribExpr(arg, env, Type.anyPoly);
+            Type argtype = allowPoly && TreeInfo.isPoly(arg, env.tree) ?
+                    deferredAttr.new DeferredType(arg, env) :
+                    chk.checkNonVoid(arg, attribExpr(arg, env, Infer.anyPoly));
             argtypes.append(argtype);
         }
         return argtypes.toList();
     }
-    
+
     /** Attribute a type argument list, returning a list of types.
      *  Caller is responsible for calling checkRefTypes.
      */
@@ -767,10 +775,12 @@
         // 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)
+        if (env.info.enclVar.annotations.pendingCompletion()) {
             env.info.lint = lintEnv.info.lint;
-        else
-            env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.attributes_field, env.info.enclVar.flags());
+        } else {
+            env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.annotations,
+                                                      env.info.enclVar.flags());
+        }
 
         Lint prevLint = chk.setLint(env.info.lint);
         JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
@@ -842,6 +852,13 @@
         return t;
     }
 
+    Type attribIdentAsEnumType(Env<AttrContext> env, JCIdent id) {
+        Assert.check((env.enclClass.sym.flags() & ENUM) != 0);
+        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)
@@ -875,7 +892,7 @@
         MethodSymbol m = tree.sym;
         boolean isDefender = (m.flags() & DEFENDER) != 0;
 
-        Lint lint = env.info.lint.augment(m.attributes_field, m.flags());
+        Lint lint = env.info.lint.augment(m.annotations, m.flags());
         Lint prevLint = chk.setLint(lint);
         MethodSymbol prevMethod = chk.setMethod(m);
         try {
@@ -967,6 +984,11 @@
                     (tree.mods.flags & (ABSTRACT | NATIVE)) == 0 &&
                     !relax)
                     log.error(tree.pos(), "missing.meth.body.or.decl.abstract");
+                if (tree.defaultValue != null) {
+                    if ((owner.flags() & ANNOTATION) == 0)
+                        log.error(tree.pos(),
+                                  "default.allowed.in.intf.annotation.member");
+                }
             } else if ((owner.flags() & INTERFACE) != 0 && !isDefender) {
                 log.error(tree.body.pos(), "intf.meth.cant.have.body");
             } else if ((tree.mods.flags & ABSTRACT) != 0) {
@@ -1025,7 +1047,7 @@
         }
 
         VarSymbol v = tree.sym;
-        Lint lint = env.info.lint.augment(v.attributes_field, v.flags());
+        Lint lint = env.info.lint.augment(v.annotations, v.flags());
         Lint prevLint = chk.setLint(lint);
 
         // Check that the variable's declared type is well-formed.
@@ -1177,7 +1199,7 @@
 
         Env<AttrContext> switchEnv =
             env.dup(tree, env.info.dup(env.info.scope.dup()));
-        
+
         try {
 
             boolean enumSwitch =
@@ -1235,7 +1257,7 @@
                     addVars(c.stats, switchEnv.info.scope);
                 }
             }
-            
+
             result = null;
         }
         finally {
@@ -1346,7 +1368,7 @@
             result = null;
         }
         finally {
-            localEnv.info.scope.leave();            
+            localEnv.info.scope.leave();
         }
     }
 
@@ -1379,61 +1401,24 @@
             }
         }
     }
-    
-    class ConditionalInfo extends ResultInfo {
-        
-        Map<Type, DiagnosticPosition> pendingChecks =
-                new LinkedHashMap<Type, DiagnosticPosition>();
-
-        public ConditionalInfo(Type pt, CheckContext checkContext) {
-            super(VAL, pt, checkContext);
-        }
-         
-        @Override
-        protected Type check(DiagnosticPosition pos, Type found) {
-            Type typeToCheck = pt;
-            if (isNumeric(found) || isBoolean(found)) {
-                typeToCheck = Type.noType;
-                pendingChecks.put(found, pos);
-            }
-            return chk.checkType(pos, found, typeToCheck, checkContext);
-        }
-        
-        void finish() {
-            for (Map.Entry<Type, DiagnosticPosition> checkEntry : pendingChecks.entrySet()) {
-                chk.checkType(checkEntry.getValue(), checkEntry.getKey(), pt, checkContext);
-            }
-        }
-
-        @Override
-        protected ResultInfo dup(Type newPt) {
-            return new ConditionalInfo(newPt, checkContext);
-        }
-    }
-    
-    boolean isNumeric(Type t) {
-        Type unbox = types.unboxedType(t);
-        if (unbox.tag != NONE) {
-            return isNumeric(unbox);
-        } else {
-            return t.tag < BOOLEAN;
-        }
-    }
-    
-    boolean isBoolean(Type t) {
-        return t.tag == BOOLEAN ||
-                types.unboxedType(t).tag == BOOLEAN;
-    }
 
     public void visitConditional(JCConditional tree) {
-        attribExpr(tree.cond, env, syms.booleanType);
-        if (allowPoly && resultInfo.pt.tag == VOID) {
+        Type condtype = attribExpr(tree.cond, env, syms.booleanType);
+
+        boolean standaloneConditional = !allowPoly ||
+                pt().tag == NONE && pt() != Type.recoveryType ||
+                isBooleanOrNumeric(env, tree);
+
+        if (!standaloneConditional && resultInfo.pt.tag == 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;
         }
-        ConditionalInfo condInfo = new ConditionalInfo(resultInfo.pt,
-                new Check.NestedCheckContext(resultInfo.checkContext) {
+        
+        ResultInfo condInfo = standaloneConditional ?
+                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
@@ -1442,60 +1427,48 @@
                         enclosingContext.report(pos, diags.fragment("incompatible.type.in.conditional", details));
                     }
                 });
-        Type truetype = attribTree(tree.truepart, env, allowLambda ? condInfo : unknownExprInfo);
-        Type falsetype = attribTree(tree.falsepart, env, allowLambda ? condInfo : unknownExprInfo);
-
-        result = check(tree, condType(tree, tree.cond.type, truetype, falsetype, condInfo), VAL, resultInfo);
+
+        Type truetype = attribTree(tree.truepart, env, condInfo);
+        Type falsetype = attribTree(tree.falsepart, env, condInfo);
+
+        Type owntype = standaloneConditional ? condType(tree, truetype, falsetype) : pt();
+        if (condtype.constValue() != null &&
+                truetype.constValue() != null &&
+                falsetype.constValue() != null) {
+            //constant folding
+            owntype = cfolder.coerce(condtype.isTrue() ? truetype : falsetype, owntype);
+        }
+        result = check(tree, owntype, VAL, resultInfo);
     }
     //where
+        @SuppressWarnings("fallthrough")
+        private boolean isBooleanOrNumeric(Env<AttrContext> env, JCExpression tree) {
+            switch (tree.getTag()) {
+                case LITERAL: return ((JCLiteral)tree).typetag < CLASS;
+                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);
+                default:
+                    Type speculativeType = deferredAttr.attribSpeculative(tree, env, unknownExprInfo).type;
+                    speculativeType = types.unboxedTypeOrType(speculativeType);
+                    return speculativeType.tag <= BOOLEAN;
+            }
+        }
+
         /** 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(JCConditional tree,
-                              Type condtype,
-                              Type thentype,
-                              Type elsetype,
-                              ConditionalInfo condInfo) {
-            Type ctype;
-            if (thentype.isErroneous() || elsetype.isErroneous()) {
-                ctype = syms.errType;
-            } else if (!allowLambda || //compatibility
-                    isNumeric(thentype) && isNumeric(elsetype) || //numeric conditional
-                    isBoolean(thentype) && isBoolean(elsetype) || //boolean conditional
-                    (condInfo.pt.tag == NONE && condInfo.pt != Type.recoveryType)) { //standalone reference conditional
-                ctype = condType1(tree, condtype, thentype, elsetype);
-            } else {
-                //poly reference conditional
-                condInfo.finish();
-                ctype = resultInfo.pt;
-            }
-
-            // 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;
-        }
-        /** 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))
@@ -1600,76 +1573,52 @@
                                     Env<AttrContext> env) {
             // Search environments outwards from the point of jump.
             Env<AttrContext> env1 = env;
-            boolean seenLambda = false;
             LOOP:
             while (env1 != null) {
-                seenLambda |= env1.tree.hasTag(LAMBDA);
                 switch (env1.tree.getTag()) {
-                case LABELLED:
-                    JCLabeledStatement labelled = (JCLabeledStatement)env1.tree;
-                    if (label == labelled.label) {
-                        if (seenLambda) {
-                            badLambdaJump(pos, tag);
-                        }
-                        // 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;
+                    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 DOLOOP:
-                case WHILELOOP:
-                case FORLOOP:
-                case FOREACHLOOP:
-                    if (label == null) {
-                        if (seenLambda) {
-                            badLambdaJump(pos, tag);
-                        }
-                        return env1.tree;
-                    }
-                    break;
-                case SWITCH:
-                    if (label == null && tag == BREAK) {
-                        if (seenLambda) {
-                            badLambdaJump(pos, tag);
-                        }
-                        return env1.tree;
-                    }
-                    break;
-                case METHODDEF:
-                case 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 == CONTINUE)
-                log.error(pos, seenLambda ?
-                    "cont.inside.lambda" :
-                    "cont.outside.loop");
+                log.error(pos, "cont.outside.loop");
             else
-                log.error(pos, seenLambda ?
-                    "break.inside.lambda" :
-                    "break.outside.switch.loop");
+                log.error(pos, "break.outside.switch.loop");
             return null;
         }
-        //where
-            private void badLambdaJump(DiagnosticPosition pos, JCTree.Tag tag) {
-                log.error(pos, tag == JCTree.Tag.CONTINUE ?
-                                    "cont.inside.lambda" :
-                                    "break.inside.lambda");
-            }
 
     public void visitReturn(JCReturn tree) {
         // Check that there is an enclosing method which is
@@ -1694,10 +1643,7 @@
     }
 
     public void visitThrow(JCThrow tree) {
-        Type owntype = attribExpr(tree.expr, env); //no target-type here!
-        if (!types.isSubtype(owntype, syms.throwableType)) {
-            log.error(tree.expr, "must.be.throwable", owntype);
-        }
+        attribExpr(tree.expr, env, syms.throwableType);
         result = null;
     }
 
@@ -1802,9 +1748,8 @@
 
                     // ...and check that it is legal in the current context.
                     // (this will also set the tree's type)
-                    Type mpt = newMethTemplate(resultInfo.pt, argtypes, typeargtypes);
-                    checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt),
-                            tree.varargsElement != null);
+                    Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
+                    checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt));
                 }
                 // Otherwise, `site' is an error type and we do nothing
             }
@@ -1818,7 +1763,7 @@
             // ... 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(resultInfo.pt, argtypes, typeargtypes);
+            Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
             localEnv.info.pendingResolutionPhase = null;
             Type mtype = attribTree(tree.meth, localEnv, new ResultInfo(VAL, mpt, resultInfo.checkContext));
 
@@ -1831,7 +1776,7 @@
                     ? ((JCFieldAccess) tree.meth).selected.type
                     : env.enclClass.sym.type;
             restype = adjustMethodReturnType(qualifier, methName, argtypes, restype);
-            
+
             chk.checkRefTypes(tree.typeargs, typeargtypes);
 
             // Check that value of resulting type is admissible in the
@@ -1864,8 +1809,7 @@
                 return restype;
             }
         }
-    
-    
+
         /** Check that given application node appears as first statement
          *  in a constructor call.
          *  @param tree   The application node
@@ -1886,7 +1830,7 @@
 
         /** Obtain a method type with given argument types.
          */
-        Type newMethTemplate(Type restype, List<Type> argtypes, List<Type> typeargtypes) {
+        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);
         }
@@ -1935,7 +1879,10 @@
 
         // Attribute clazz expression and store
         // symbol + type back into the attributed tree.
-        Type clazztype = attribType(clazz, env);
+        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) {
@@ -1961,19 +1908,6 @@
         List<Type> argtypes = attribArgs(tree.args, localEnv);
         List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
 
-        if (TreeInfo.isDiamond(tree) && !clazztype.isErroneous()) {
-            Pair<Symbol, Type> diamondResult =
-                    attribDiamond(localEnv, resultInfo, tree, clazztype, argtypes, typeargtypes);
-            tree.clazz.type = types.createErrorType(clazztype);
-            tree.constructor = diamondResult.fst;
-            tree.constructorType = diamondResult.snd;
-            if (!diamondResult.snd.isErroneous()) {
-                tree.clazz.type = clazztype = diamondResult.snd.getReturnType();
-                tree.constructorType = types.createMethodTypeWithReturn(diamondResult.snd, syms.voidType);
-            }
-            clazztype = chk.checkClassType(tree.clazz, tree.clazz.type, true);
-        }
-
         // If we have made no mistakes in the class type...
         if (clazztype.tag == CLASS) {
             // Enums may not be instantiated except implicitly
@@ -2000,12 +1934,51 @@
                 // Error recovery: pretend no arguments were supplied.
                 argtypes = List.nil();
                 typeargtypes = List.nil();
+            } else if (TreeInfo.isDiamond(tree)) {
+                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
             // that we are referring to a superclass instance of the
             // current instance (JLS ???).
-            else if (!TreeInfo.isDiamond(tree)) {
+            else {
                 //the following code alters some of the fields in the current
                 //AttrContext - hence, the current context must be dup'ed in
                 //order to avoid downstream failures
@@ -2019,45 +1992,11 @@
                             clazztype,
                             tree.constructor,
                             rsEnv,
-                            new ResultInfo(VAL, newMethTemplate(syms.voidType, argtypes, typeargtypes)),
-                            rsEnv.info.lastResolveVarargs());
+                            new ResultInfo(MTH, newMethodTemplate(syms.voidType, argtypes, typeargtypes)));
                     if (rsEnv.info.lastResolveVarargs())
                         Assert.check(tree.constructorType.isErroneous() || tree.varargsElement != null);
                 }
-                if (tree.def == null &&
-                        !clazztype.isErroneous() &&
-                        clazztype.getTypeArguments().nonEmpty() &&
-                        findDiamonds &&
-                        runDiamondFinder(tree, resultInfo.checkContext.deferredAttrContext())) {
-                    Filter<JCDiagnostic> prevDeferDiagsFilter = log.deferredDiagFilter;
-                    Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
-                    Type inferredConstructorType = null;
-                    try {
-                        //disable diamond-related diagnostics
-                        log.deferAll();
-                        log.deferredDiagnostics = ListBuffer.lb();
-                        inferredConstructorType = attribDiamond(localEnv,
-                                resultInfo,
-                                tree,
-                                clazztype,
-                                Type.map(argtypes, deferredAttr.new CheckDeferredTypeMap()),
-                                typeargtypes).snd;
-                    } finally {
-                        log.deferredDiagFilter = prevDeferDiagsFilter;
-                        log.deferredDiagnostics = prevDeferredDiags;
-                    }
-                    Type inferred = null;
-                    if (!inferredConstructorType.isErroneous()) {
-                        inferred = inferredConstructorType.getReturnType();
-                    }
-                    if (inferred != null &&
-                            types.isAssignable(inferred, pt().tag == NONE ? syms.objectType : pt(), Warner.noWarnings)) {
-                        String key = types.isSameType(clazztype, inferred) ?
-                            "diamond.redundant.args" :
-                            "diamond.redundant.args.1";
-                        log.warning(tree.clazz.pos(), key, clazztype, inferred);
-                    }
-                }
+                findDiamondIfNeeded(localEnv, tree, clazztype);
             }
 
             if (cdef != null) {
@@ -2124,8 +2063,7 @@
                     clazztype,
                     tree.constructor,
                     localEnv,
-                    new ResultInfo(VAL, newMethTemplate(syms.voidType, argtypes, typeargtypes)),
-                    localEnv.info.lastResolveVarargs());
+                    new ResultInfo(VAL, newMethodTemplate(syms.voidType, argtypes, typeargtypes)));
             }
 
             if (tree.constructor != null && tree.constructor.kind == MTH)
@@ -2134,89 +2072,59 @@
         result = check(tree, owntype, VAL, resultInfo);
         chk.validate(tree.typeargs, localEnv);
     }
-    
-    boolean runDiamondFinder(JCNewClass tree, DeferredAttrContext deferredAttrContext) {
-        if (deferredAttrContext == deferredAttr.emptyDeferredAttrContext) {
-            return true;
-        } else {
-            return deferredAttrContext.mode == DeferredAttr.AttrMode.CHECK &&
-                    !resultInfo.checkContext.inferenceContext().free(resultInfo.pt);
-        }
-    }
-    
-    Pair<Symbol, Type> attribDiamond(Env<AttrContext> env,
-                        ResultInfo resultInfo,
-                        final JCNewClass tree,
-                        final Type clazztype,
-                        List<Type> argtypes,
-                        List<Type> typeargtypes) {
-        if (clazztype.isErroneous() ||
-                clazztype.isInterface()) {
-            //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 new Pair<Symbol, Type>(syms.noSymbol, clazztype);
-        }
-
-        //dup attribution environment and augment the set of inference variables
-        Env<AttrContext> localEnv = env.dup(tree);
-
-        ClassType site = new ClassType(clazztype.getEnclosingType(),
-                    clazztype.tsym.type.getTypeArguments(),
-                    clazztype.tsym);
-
-        //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(),
-                    localEnv,
-                    site,
-                    argtypes,
-                    typeargtypes);
-
-        Type constructorType = types.createErrorType(clazztype);
-        ResultInfo diamondResult = new ResultInfo(VAL, newMethTemplate(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", clazztype.tsym), details));
-            }
-        });
-        constructorType = checkId(tree, site,
-                constructor,
-                localEnv,
-                diamondResult,
-                localEnv.info.lastResolveVarargs());
-
-        return new Pair<Symbol, Type>(constructor.baseSymbol(), constructorType);
-    }
-
-    private void checkLambdaCandidate(JCNewClass tree, ClassSymbol csym, Type clazztype) {
-            if (allowLambda &&
-                    identifyLambdaCandidate &&
-                    clazztype.tag == CLASS &&
-                    pt().tag != NONE &&
-                    types.isSam(clazztype.tsym)) {
-                Symbol samDescriptor = 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(samDescriptor.name)) continue;
-                    Type mtype = types.memberType(clazztype, sym);
-                    if (types.overrideEquivalent(mtype, types.memberType(clazztype, samDescriptor))) {
-                        found = true;
+    //where
+        void findDiamondIfNeeded(Env<AttrContext> env, JCNewClass tree, Type clazztype) {
+            if (tree.def == null &&
+                    !clazztype.isErroneous() &&
+                    clazztype.getTypeArguments().nonEmpty() &&
+                    findDiamonds) {
+                JCTypeApply ta = (JCTypeApply)tree.clazz;
+                List<JCExpression> prevTypeargs = ta.arguments;
+                try {
+                    //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;
+                    if (!inferred.isErroneous() &&
+                        types.isAssignable(inferred, pt().tag == NONE ? syms.objectType : 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 (found && count == 1) {
-                    log.note(tree.def, "potential.lambda.found");
+                } finally {
+                    ta.arguments = prevTypeargs;
                 }
             }
         }
 
+            private void checkLambdaCandidate(JCNewClass tree, ClassSymbol csym, Type clazztype) {
+                if (allowLambda &&
+                        identifyLambdaCandidate &&
+                        clazztype.tag == CLASS &&
+                        pt().tag != 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");
+                    }
+                }
+            }
+
     /** Make an attributed null check tree.
      */
     public JCExpression makeNullCheck(JCExpression arg) {
@@ -2292,9 +2200,9 @@
                 attribStats(that.params, localEnv);
                 explicitParamTypes = TreeInfo.types(that.params);
             }
-            
-            Type target = infer.inferSAM(that, pt(), explicitParamTypes, resultInfo.checkContext);
-            Type lambdaType = target == Type.recoveryType ?
+
+            Type target = infer.instantiateFunctionalInterface(that, pt(), explicitParamTypes, resultInfo.checkContext);
+            Type lambdaType = (target == Type.recoveryType) ?
                     fallbackDescriptorType(that) :
                     types.findDescriptorType(target);
 
@@ -2302,13 +2210,13 @@
                 //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;                        
+                        arityMismatch = true;
                     }
                     //reset previously set info
                     Type argType = arityMismatch ?
@@ -2322,11 +2230,11 @@
                     params = params.tail;
                 }
 
-                //attribute lambda parameters                
+                //attribute lambda parameters
                 attribStats(that.params, localEnv);
-                
+
                 if (arityMismatch) {
-                    resultInfo.checkContext.report(that, diags.fragment("infer.incompatible.arg.types.in.lambda"));
+                    resultInfo.checkContext.report(that, diags.fragment("incompatible.arg.types.in.lambda"));
                         result = that.type = types.createErrorType(target);
                         return;
                 }
@@ -2349,21 +2257,22 @@
                 JCBlock body = (JCBlock)that.body;
                 attribStats(body.stats, localEnv);
             }
-            
+
             result = check(that, target, VAL, resultInfo);
-            
+
             boolean isSpeculativeRound =
                     resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE;
-            
+
             postAttr(that);
             flow.analyzeLambda(env, that, make, isSpeculativeRound);
-            
+
             checkLambdaCompatible(that, lambdaType, resultInfo.checkContext, isSpeculativeRound);
-            
+
             if (!isSpeculativeRound) {
                 checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, target);
             }
-        } catch (Types.SAMConversionFailure ex) {
+            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());
@@ -2399,7 +2308,6 @@
         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() {
@@ -2414,7 +2322,7 @@
                 }
             } 
         }
-        
+
         /**
          * Lambda/method reference have a special check context that ensures
          * that i.e. a lambda return type is compatible with the expected
@@ -2434,23 +2342,230 @@
             }
             @Override
             public void report(DiagnosticPosition pos, JCDiagnostic details) {
-                enclosingContext.report(pos, diags.fragment("infer.incompatible.ret.types.in.lambda", details));
+                enclosingContext.report(pos, diags.fragment("incompatible.ret.type.in.lambda", details));
+            }
+        }
+
+        /**
+        * 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) thrown types must be 'included' in the thrown types list of the expected
+        * descriptor.
+        */
+        private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext, boolean speculativeAttr) {
+            Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType(), types);
+
+            //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.tag != 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(), types);
+            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(), types);
+                if (chk.unhandled(tree.inferredThrownTypes == null ? List.<Type>nil() : tree.inferredThrownTypes, thrownTypes).nonEmpty()) {
+                    log.error(tree, "incompatible.thrown.types.in.lambda", tree.inferredThrownTypes);
+                }
             }
         }
 
-    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(0, names.lambda, null,
-                                 env.info.scope.owner);
-        } else {
-            lambdaEnv = env.dup(that, env.info.dup(env.info.scope.dup()));
+        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(0, 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().tag == NONE && pt() != Type.recoveryType)) {
+            if (pt().tag == 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;
         }
-        return lambdaEnv;
+        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, new ResultInfo(that.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType));
+
+            if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
+                exprType = chk.checkConstructorRefType(that.expr, exprType);
+            }
+
+            if (exprType.isErroneous()) {
+                //if the qualifier expression contains problems,
+                //give up atttribution of method reference
+                result = that.type = exprType;
+                return;
+            }
+
+            if (TreeInfo.isStaticSelector(that.expr, names) &&
+                    (that.getMode() != ReferenceMode.NEW || !that.expr.type.isRaw())) {
+                //if the qualifier is a type, validate it
+                chk.validate(that.expr, env);
+            }
+
+            //attrib type-arguments
+            List<Type> typeargtypes = null;
+            if (that.typeargs != null) {
+                typeargtypes = attribTypes(that.typeargs, localEnv);
+            }
+
+            Type target = infer.instantiateFunctionalInterface(that, pt(), null, resultInfo.checkContext);
+            Type desc = (target == Type.recoveryType) ?
+                    fallbackDescriptorType(that) :
+                    types.findDescriptorType(target);
+
+            List<Type> argtypes = desc.getParameterTypes();
+
+            boolean allowBoxing =
+                    resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
+                    resultInfo.checkContext.deferredAttrContext().phase.isBoxingRequired();
+            Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = rs.resolveMemberReference(that.pos(), localEnv, that,
+                    that.expr.type, that.name, argtypes, typeargtypes, allowBoxing);
+
+            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) {
+                    resultInfo.checkContext.report(that, diag);
+                } else if (!targetError) {
+                    log.report(diag);
+                }
+                result = that.type = types.createErrorType(target);
+                return;
+            }
+
+            if (desc.getReturnType() == Type.recoveryType) {
+                // stop here
+                result = that.type = types.createErrorType(target);
+                return;
+            }
+
+            that.sym = refSym.baseSymbol();
+            that.kind = lookupHelper.referenceKind(that.sym);
+
+            ResultInfo checkInfo =
+                    resultInfo.dup(newMethodTemplate(
+                        desc.getReturnType().tag == VOID ? Type.noType : desc.getReturnType(),
+                        lookupHelper.argtypes,
+                        typeargtypes));
+
+            Type refType = checkId(that, lookupHelper.site, refSym, localEnv, checkInfo);
+
+            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;
+        }
+    }
+
+    @SuppressWarnings("fallthrough")
+    void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
+        Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType(), types);
+
+        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.tag == VOID) {
+            incompatibleReturnType = null;
+        }
+
+        if (returnType.tag != VOID && resType.tag != VOID) {
+            if (resType.isErroneous() ||
+                    new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.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(), types);
+            if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) {
+                log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes());
+            }
+        }
     }
 
     public void visitParens(JCParens tree) {
@@ -2590,29 +2705,27 @@
         //a fresh environment is required for 292 inference to work properly ---
         //see Infer.instantiatePolymorphicSignatureInstance()
         Env<AttrContext> localEnv = env.dup(tree);
-        final boolean polyExpr;
         //should we propagate the target type?
-        switch (TreeInfo.skipParens(tree.expr).getTag()) {
-            case LAMBDA:
-            case REFERENCE:
-            case CONDEXPR:
-                polyExpr = true;
-                break;
-            default:
-                polyExpr = false;
+        final ResultInfo castInfo;
+        final boolean isPoly = TreeInfo.isPoly(tree.expr, tree);
+        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;
         }
-        ResultInfo castInfo = polyExpr ? 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);
-            }
-        }) : unknownExprInfo;
         Type exprtype = attribTree(tree.expr, localEnv, castInfo);
-        Type owntype = polyExpr ? clazztype : chk.checkCastable(tree.expr.pos(), exprtype, clazztype);        
+        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, resultInfo);
-        if (!polyExpr)
+        if (!isPoly)
             chk.checkRedundantCast(localEnv, tree);
     }
 
@@ -2640,7 +2753,6 @@
 
     public void visitIdent(JCIdent tree) {
         Symbol sym;
-        boolean varArgs = false;
 
         // Find symbol
         if (pt().tag == METHOD || pt().tag == FORALL) {
@@ -2648,7 +2760,6 @@
             // method type with the type of the call's arguments as parameters.
             env.info.pendingResolutionPhase = null;
             sym = rs.resolveMethod(tree.pos(), env, tree.name, pt().getParameterTypes(), pt().getTypeArguments());
-            varArgs = env.info.lastResolveVarargs();
         } else if (tree.sym != null && tree.sym.kind != VAR) {
             sym = tree.sym;
         } else {
@@ -2687,17 +2798,6 @@
             // illegal forward reference.
             checkInit(tree, env, v, false);
 
-            // If symbol is a local variable accessed from an embedded
-            // inner class (not a lambda!) check that it is final.
-            if (!allowEffectivelyFinalInInnerClasses &&
-                    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)
@@ -2721,215 +2821,7 @@
             while (env1.outer != null && !rs.isAccessible(env, env1.enclClass.sym.type, sym))
                 env1 = env1.outer;
         }
-        result = checkId(tree, env1.enclClass.sym.type, sym, env, resultInfo, varArgs);
-    }
-
-    @Override
-    public void visitReference(final JCMemberReference that) {
-        if (pt().isErroneous() || (pt().tag == NONE && pt() != Type.recoveryType)) {
-            if (pt().tag == NONE) {
-                //method reference only allowed in assignment or method invocation/cast context
-                log.error(that.pos(), "unexpected.meth.reference");
-            }
-            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, new ResultInfo(that.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType));
-            
-            if (that.getMode() == JCMemberReference.ReferenceMode.NEW) {
-                exprType = chk.checkConstructorRefType(that.expr, exprType);
-            }
-
-            if (exprType.isErroneous()) {
-                //if the qualifier expression contains problems,
-                //give up atttribution of method reference
-                result = that.type = exprType;
-                return;
-            }
-
-            if (TreeInfo.isStaticSelector(that.expr, names) &&
-                    (that.getMode() != ReferenceMode.NEW || !that.expr.type.isRaw())) {
-                //if the qualifier is a type, validate it
-                chk.validate(that.expr, env);
-            }
-            
-            //attrib type-arguments
-            List<Type> typeargtypes = null;
-            if (that.typeargs != null) {
-                typeargtypes = attribTypes(that.typeargs, localEnv);
-            }
-            
-            Type target = infer.inferSAM(that, pt(), null, resultInfo.checkContext);
-            Type desc = target == Type.recoveryType ?
-                    fallbackDescriptorType(that) :
-                    types.findDescriptorType(target);
-
-            List<Type> argtypes = desc.getParameterTypes();
-            
-            boolean allowBoxing =
-                    resultInfo.checkContext.deferredAttrContext() == deferredAttr.emptyDeferredAttrContext ||
-                    resultInfo.checkContext.deferredAttrContext().phase.isBoxingRequired();
-            Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = rs.resolveMemberReference(that.pos(), localEnv, that,
-                    that.expr.type, that.name, argtypes, typeargtypes, allowBoxing);
-            
-            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.reference", Kinds.kindName(that.getMode()), detailsDiag);
-                
-                if (targetError) {
-                    resultInfo.checkContext.report(that, diag);
-                } else {
-                    log.report(diag);
-                }
-                result = that.type = types.createErrorType(target);
-                return;
-            }
-            
-            if (desc.getReturnType() == Type.recoveryType) {                
-                // stop here
-                result = that.type = types.createErrorType(target);
-                return;
-            }
-            
-            that.sym = refSym.baseSymbol();
-            that.kind = lookupHelper.referenceKind(that.sym);
-            
-            ResultInfo checkInfo =
-                    resultInfo.dup(newMethTemplate(
-                        desc.getReturnType().tag == VOID ? Type.noType : desc.getReturnType(),
-                        lookupHelper.argtypes,
-                        typeargtypes));
-            
-            Type refType = checkId(that, lookupHelper.site,
-                    refSym, localEnv, checkInfo, localEnv.info.lastResolveVarargs());
-            
-            if (!refType.isErroneous()) {
-                refType = types.createMethodTypeWithReturn(refType,
-                        adjustMethodReturnType(lookupHelper.site, that.name, checkInfo.pt.getParameterTypes(), refType.getReturnType()));
-            }
-
-            //go ahead with standard SAM 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.SAMConversionFailure ex) {
-            JCDiagnostic cause = ex.getDiagnostic();
-            resultInfo.checkContext.report(that, cause);
-            result = that.type = types.createErrorType(pt());
-            return;
-        }
-    }
-
-    /**
-     * SAM compatibility. Check that given return types, thrown types, parameter types
-     * are compatible with the expected SAM descriptor. This means that (i) parameter
-     * types must be identical to those of the target SAM descriptor; (ii) return
-     * types must be compatible with the return type of the expected SAM descriptor;
-     * thrown types must be 'included' in the thrown types list of the expected
-     * SAM descriptor.
-     */
-    void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext, boolean speculativeAttr) {
-        Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType(), types);
-
-        //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.tag != VOID && returnType != Type.recoveryType) {
-            checkContext.report(tree, diags.fragment("infer.incompatible.ret.types.in.lambda",
-                    diags.fragment("missing.ret.val", returnType)));
-        }
-        
-        List<Type> argTypes = checkContext.inferenceContext().asFree(descriptor.getParameterTypes(), types);
-        if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) {
-            checkContext.report(tree, diags.fragment("infer.incompatible.arg.types.in.lambda"));
-        }
-
-        if (!speculativeAttr) {
-            List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes(), types);
-            if (chk.unhandled(tree.inferredThrownTypes == null ? List.<Type>nil() : tree.inferredThrownTypes, thrownTypes).nonEmpty()) {
-                log.error(tree, "incompatible.thrown.types.in.lambda", tree.inferredThrownTypes);
-            }
-        }
-    }
-    
-    @SuppressWarnings("fallthrough")
-    void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) {
-        Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType(), types);
-        
-        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.tag == VOID) {
-            incompatibleReturnType = null;
-        }
-
-        if (returnType.tag != VOID && resType.tag != VOID) {
-            if (resType.isErroneous() ||
-                    new LambdaReturnContext(checkContext).compatible(resType, returnType, Warner.noWarnings)) {
-                incompatibleReturnType = null;
-            }
-        }
-
-        if (incompatibleReturnType != null) {
-            checkContext.report(tree, diags.fragment("infer.incompatible.ret.types.in.lambda",
-                    diags.fragment("inconvertible.types", resType, descriptor.getReturnType())));
-        }
-
-        if (!speculativeAttr) {
-            List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes(), types);
-            if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) {
-                log.error(tree, "incompatible.thrown.types.in.lambda", refType.getThrownTypes());
-            }
-        }
+        result = checkId(tree, env1.enclClass.sym.type, sym, env, resultInfo);
     }
 
     public void visitSelect(JCFieldAccess tree) {
@@ -2946,7 +2838,7 @@
         }
 
         // Attribute the qualifier expression, and determine its symbol (if any).
-        Type site = attribTree(tree.selected, env, new ResultInfo(skind, Type.anyPoly));
+        Type site = attribTree(tree.selected, env, new ResultInfo(skind, Infer.anyPoly));
         if ((pkind() & (PCK | TYP)) == 0)
             site = capture(site); // Capture field access
 
@@ -3054,7 +2946,7 @@
         }
 
         env.info.selectSuper = selectSuperPrev;
-        result = checkId(tree, site, sym, env, resultInfo, varArgs);
+        result = checkId(tree, site, sym, env, resultInfo);
     }
     //where
         /** Determine symbol referenced by a Select expression,
@@ -3166,22 +3058,24 @@
          *  @param env        The current environment.
          *  @param resultInfo    The expected result
          */
-        @SuppressWarnings("fallthrough")
         Type checkId(JCTree tree,
                      Type site,
                      Symbol sym,
                      Env<AttrContext> env,
-                     ResultInfo resultInfo,
-                     boolean useVarargs) {
+                     ResultInfo resultInfo) {
             boolean isPMeth = 
                     resultInfo.pt.tag == FORALL || resultInfo.pt.tag == METHOD;
             Type pt = isPMeth &&
                     !site.isErroneous() ?
-                        resultInfo.pt.map(deferredAttr.new SpeculativeDeferredTypeMap(sym, env.info.pendingResolutionPhase)) :
+                        resultInfo.pt.map(deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)) :
                         resultInfo.pt;
+
+            DeferredAttr.DeferredTypeMap recoveryMap =
+                    deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
             
-            if ((isPMeth && site.isErroneous()) || pt.isErroneous()) {
-                recoveryAttribArgs(env, resultInfo, sym, false);
+            if (pt.isErroneous()) {
+                if (!site.isErroneous() && isPMeth)
+                    Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
                 return types.createErrorType(site);
             }
             Type owntype; // The computed type of this identifier occurrence.
@@ -3264,9 +3158,9 @@
                         resultInfo.pt.getTypeArguments());
                 break;
             }
-            case ERR:
-                recoveryAttribArgs(env, resultInfo, sym, true);
-            case PCK: 
+            case PCK: case ERR:
+                if (!site.isErroneous() && isPMeth)
+                    Type.map(resultInfo.pt.getParameterTypes(), recoveryMap);
                 owntype = sym.type;
                 break;
             default:
@@ -3287,15 +3181,6 @@
             // kind are compatible with the prototype and protokind.
             return check(tree, owntype, sym.kind, resultInfo);
         }
-        //where
-            void recoveryAttribArgs(Env<AttrContext> env, ResultInfo resultInfo, Symbol sym, boolean silent) {
-                for (Type t : resultInfo.pt.getParameterTypes()) {
-                    if (t.tag == DEFERRED) {
-                        DeferredAttr.DeferredType<?> dt = (DeferredAttr.DeferredType<?>)t;
-                        attribTree(dt.tree, dt.env, silent ? silentRecoveryInfo : recoveryInfo);
-                    }
-                }
-            }
 
         /** Check that variable is initialized and evaluate the variable's
          *  initializer, if not yet done. Also check that variable is not
@@ -3405,7 +3290,10 @@
         }
 
     Warner noteWarner = new Warner();
-    
+
+    /**
+     * Check that method arguments conform to its instantiation.
+     **/
     public Type checkMethod(Type site,
                             Symbol sym,
                             ResultInfo resultInfo,
@@ -3450,6 +3338,9 @@
             //depending on the current check context
             resultInfo.checkContext.report(env.tree.pos(), ex.getDiagnostic());
             return types.createErrorType(site);
+        } catch (Resolve.InapplicableMethodException ex) {
+            Assert.error(ex.getDiagnostic().getMessage(Locale.getDefault()));
+            return null;
         }
     }
 
@@ -3752,7 +3643,7 @@
                 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.annotations, c.flags());
 
             Lint prevLint = chk.setLint(env.info.lint);
             JavaFileObject prev = log.useSource(c.sourcefile);
@@ -3819,6 +3710,26 @@
             if (tree.typarams.nonEmpty())
                 log.error(tree.typarams.head.pos(),
                           "intf.annotation.cant.have.type.params");
+
+            // If this annotation has a @ContainedBy, validate
+            Attribute.Compound containedBy = c.attribute(syms.containedByType.tsym);
+            if (containedBy != null) {
+                // get diagnositc position for error reporting
+                DiagnosticPosition cbPos = getDiagnosticPosition(tree, containedBy.type);
+                Assert.checkNonNull(cbPos);
+
+                chk.validateContainedBy(c, containedBy, cbPos);
+            }
+
+            // If this annotation has a @ContainerFor, validate
+            Attribute.Compound containerFor = c.attribute(syms.containerForType.tsym);
+            if (containerFor != null) {
+                // get diagnositc position for error reporting
+                DiagnosticPosition cfPos = getDiagnosticPosition(tree, containerFor.type);
+                Assert.checkNonNull(cfPos);
+
+                chk.validateContainerFor(c, containerFor, cfPos);
+            }
         } else {
             // Check that all extended classes and interfaces
             // are compatible (i.e. no two define methods with same arguments
@@ -3883,6 +3794,16 @@
         }
     }
         // where
+        /** 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 {
@@ -4037,7 +3958,7 @@
         public void visitReference(JCMemberReference that) {
             super.visitReference(that);
             if (that.sym == null) {
-                that.sym = new MethodSymbol(0, names.lambda, syms.unknownType, syms.noSymbol);
+                that.sym = new MethodSymbol(0, names.empty, syms.unknownType, syms.noSymbol);
             }
         }
     }
--- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -66,12 +66,12 @@
      * useful for detecting self-references in variable initializers
      */
     Symbol enclVar = null;
-    
-    /** The variable whose initializer is being attributed
-     * useful for detecting self-references in variable initializers
+
+    /** ResultInfo to be used for attributing 'return' statement expressions
+     * (set by Attr.visitMethod and Attr.visitLambda)
      */
     Attr.ResultInfo returnResult = null;
-    
+
     /** Duplicate this context, replacing scope field and copying all others.
      */
     AttrContext dup(Scope scope) {
@@ -98,7 +98,7 @@
             return List.nil();
         return scope.getElements();
     }
-    
+
     boolean lastResolveVarargs() {
         return pendingResolutionPhase != null &&
                 pendingResolutionPhase.isVarargsRequired();
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Oct 25 23:25:08 2012 +0100
@@ -40,6 +40,7 @@
 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.InferenceContext.FreeTypeListener;
 
@@ -49,7 +50,6 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.code.TypeTags.WILDCARD;
-import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext;
 
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
@@ -73,7 +73,6 @@
     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;
@@ -120,7 +119,6 @@
         allowDefenderMethods = source.allowDefenderMethods();
         allowPreciseCheckConflict = source.allowPreciseCheckConflict();
         complexInference = options.isSet("complexinference");
-        skipAnnotations = options.isSet("skipAnnotations");
         warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
         suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
         enableSunApiLintControl = options.isSet("enableSunApiLintControl");
@@ -140,7 +138,7 @@
         sunApiHandler = new MandatoryWarningHandler(log, verboseSunApi,
                 enforceMandatoryWarnings, "sunapi", null);
 
-        deferredLintHandler = DeferredLintHandler.immediateHandler;        
+        deferredLintHandler = DeferredLintHandler.immediateHandler;
     }
 
     /** Switch: generics enabled?
@@ -465,10 +463,12 @@
          * Obtain a warner for this check context
          */
         public Warner checkWarner(DiagnosticPosition pos, Type found, Type req);
-        
+
         public Infer.InferenceContext inferenceContext();
-        
+
         public DeferredAttr.DeferredAttrContext deferredAttrContext();
+
+        public boolean allowBoxing();
     }
 
     /**
@@ -503,6 +503,10 @@
         public DeferredAttrContext deferredAttrContext() {
             return enclosingContext.deferredAttrContext();
         }
+
+        public boolean allowBoxing() {
+            return enclosingContext.allowBoxing();
+        }
     }
 
     /**
@@ -527,6 +531,10 @@
         public DeferredAttrContext deferredAttrContext() {
             return deferredAttr.emptyDeferredAttrContext;
         }
+
+        public boolean allowBoxing() {
+            return true;
+        }
     };
 
     /** Check that a given type is assignable to a given proto-type.
@@ -590,8 +598,7 @@
         if (!tree.type.isErroneous() &&
                 (env.info.lint == null || env.info.lint.isEnabled(Lint.LintCategory.CAST))
                 && types.isSameType(tree.expr.type, tree.clazz.type)
-                && !is292targetTypeCast(tree)
-                && !isLambdaOrMethodReference(tree.expr)) {
+                && !is292targetTypeCast(tree)) {
             log.warning(Lint.LintCategory.CAST,
                     tree.pos(), "redundant.cast", tree.expr.type);
         }
@@ -609,12 +616,6 @@
                 }
                 return is292targetTypeCast;
             }
-            
-            private boolean isLambdaOrMethodReference(JCExpression tree) {
-                  JCExpression expr = TreeInfo.skipParens(tree);
-                  return expr.hasTag(LAMBDA) ||
-                          expr.hasTag(REFERENCE);
-            }
 
 
 
@@ -675,7 +676,7 @@
         else
             return t;
     }
-    
+
     /** Check that type is a valid qualifier for a constructor reference expression
      */
     Type checkConstructorRefType(DiagnosticPosition pos, Type t) {
@@ -884,6 +885,8 @@
                 sym.owner == syms.enumSym)
                 formals = formals.tail.tail;
         List<JCExpression> args = argtrees;
+        DeferredAttr.DeferredTypeMap checkDeferredMap =
+                deferredAttr.new DeferredTypeMap(DeferredAttr.AttrMode.CHECK, sym, env.info.pendingResolutionPhase);
         if (args != null) {
             //this is null when type-checking a method reference
             while (formals.head != last) {
@@ -904,7 +907,7 @@
             } else if ((sym.flags() & VARARGS) != 0 && allowVarargs) {
                 // non-varargs call to varargs method
                 Type varParam = owntype.getParameterTypes().last();
-                Type lastArg = deferredAttr.new CheckDeferredTypeMap().apply(argtypes.last());
+                Type lastArg = checkDeferredMap.apply(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",
@@ -917,7 +920,7 @@
                     kindName(sym),
                     sym.name,
                     rs.methodArguments(sym.type.getParameterTypes()),
-                    rs.methodArguments(Type.map(argtypes, deferredAttr.new CheckDeferredTypeMap())),
+                    rs.methodArguments(Type.map(argtypes, checkDeferredMap)),
                     kindName(sym.location()),
                     sym.location());
            owntype = new MethodType(owntype.getParameterTypes(),
@@ -963,7 +966,7 @@
                 && types.isSubtypeUnchecked(actual, types.interfaces(formal), warn))
                 return;
         }
-        
+
     /**
      * Check that type 't' is a valid instantiation of a generic class
      * (see JLS 4.5)
@@ -2528,9 +2531,12 @@
         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
@@ -2575,14 +2581,13 @@
     /** 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 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))
@@ -2594,6 +2599,231 @@
         }
     }
 
+    /**
+     * Validate the proposed container 'containedBy' on the
+     * annotation type symbol 's'. Report errors at position
+     * 'pos'.
+     *
+     * @param s The (annotation)type declaration annotated with a @ContainedBy
+     * @param containerAnno the @ContainedBy on 's'
+     * @param pos where to report errors
+     */
+    public void validateContainedBy(TypeSymbol s, Attribute.Compound containedBy, DiagnosticPosition pos) {
+        Assert.check(types.isSameType(containedBy.type, syms.containedByType));
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containedBy.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containedby", s, containedBy);
+            return;
+        }
+
+        validateHasContainerFor(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);
+    }
+
+    /**
+     * Validate the proposed container 'containerFor' on the
+     * annotation type symbol 's'. Report errors at position
+     * 'pos'.
+     *
+     * @param s The (annotation)type declaration annotated with a @ContainerFor
+     * @param containerFor the @ContainedFor on 's'
+     * @param pos where to report errors
+     */
+    public void validateContainerFor(TypeSymbol s, Attribute.Compound containerFor, DiagnosticPosition pos) {
+        Assert.check(types.isSameType(containerFor.type, syms.containerForType));
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containerFor.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containerfor", s, containerFor);
+            return;
+        }
+
+        validateHasContainedBy(t.tsym, s, pos);
+    }
+
+    private void validateHasContainedBy(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
+        Attribute.Compound containedBy = container.attribute(syms.containedByType.tsym);
+
+        if (containedBy == null) {
+            log.error(pos, "invalid.container.no.containedby", container, syms.containedByType.tsym);
+            return;
+        }
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containedBy.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containedby", container, contained);
+            return;
+        }
+
+        if (!types.isSameType(t, contained.type))
+            log.error(pos, "invalid.container.wrong.containedby", t.tsym, contained);
+    }
+
+    private void validateHasContainerFor(TypeSymbol container, TypeSymbol contained, DiagnosticPosition pos) {
+        Attribute.Compound containerFor = container.attribute(syms.containerForType.tsym);
+
+        if (containerFor == null) {
+            log.error(pos, "invalid.container.no.containerfor", container, syms.containerForType.tsym);
+            return;
+        }
+
+        Type t = null;
+        List<Pair<MethodSymbol,Attribute>> l = containerFor.values;
+        if (!l.isEmpty()) {
+            Assert.check(l.head.fst.name == names.value);
+            t = ((Attribute.Class)l.head.snd).getValue();
+        }
+
+        if (t == null) {
+            log.error(pos, "invalid.container.wrong.containerfor", container, contained);
+            return;
+        }
+
+        if (!types.isSameType(t, contained.type))
+            log.error(pos, "invalid.container.wrong.containerfor", t.tsym, contained);
+    }
+
+    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.containedby.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.containedby.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.containedby.annotation.not.inherited", container, contained);
+            }
+        }
+    }
+
+    private void validateTarget(Symbol container, Symbol contained, DiagnosticPosition pos) {
+        Attribute.Array containedTarget = getAttributeTargetAttribute(contained);
+
+        // If contained has no Target, we are done
+        if (containedTarget == null) {
+            return;
+        }
+
+        // If contained has Target m1, container must have a Target
+        // annotation, m2, and m2 must be a subset of m1. (This is
+        // trivially true if contained has no target as per above).
+
+        // contained has target, but container has not, error
+        Attribute.Array containerTarget = getAttributeTargetAttribute(container);
+        if (containerTarget == null) {
+            log.error(pos, "invalid.containedby.annotation.incompatible.target", container, contained);
+            return;
+        }
+
+        Set<Name> 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 = 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 (!isTargetSubset(containedTargets, containerTargets)) {
+            log.error(pos, "invalid.containedby.annotation.incompatible.target", container, contained);
+        }
+    }
+
+    /** Checks that t is a subset of s, with respect to ElementType
+     * semantics, specifically {ANNOTATION_TYPE} is a subset of {TYPE}
+     */
+    private boolean isTargetSubset(Set<Name> s, Set<Name> t) {
+        // Check that all elements in t are present in s
+        for (Name n2 : t) {
+            boolean currentElementOk = false;
+            for (Name n1 : s) {
+                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.containedby.annotation.elem.nondefault",
+                          container,
+                          elm);
+            }
+        }
+    }
+
     /** Is s a method symbol that overrides a method in a superclass? */
     boolean isOverrider(Symbol s) {
         if (s.kind != MTH || s.isStatic())
@@ -2614,12 +2844,10 @@
 
     /** Is the annotation applicable to the symbol? */
     boolean annotationApplicable(JCAnnotation a, Symbol s) {
-        Attribute.Compound atTarget =
-            a.annotationType.type.tsym.attribute(syms.annotationTargetType.tsym);
-        if (atTarget == null) return true;
-        Attribute atValue = atTarget.member(names.value);
-        if (!(atValue instanceof Attribute.Array)) return true; // error recovery
-        Attribute.Array arr = (Attribute.Array) atValue;
+        Attribute.Array arr = getAttributeTargetAttribute(a.annotationType.type.tsym);
+        if (arr == null) {
+            return true;
+        }
         for (Attribute app : arr.values) {
             if (!(app instanceof Attribute.Enum)) return true; // recovery
             Attribute.Enum e = (Attribute.Enum) app;
@@ -2661,6 +2889,16 @@
         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;
+    }
+
     /** Check an annotation value.
      */
     public void validateAnnotation(JCAnnotation a) {
--- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java	Thu Oct 25 23:25:08 2012 +0100
@@ -26,29 +26,29 @@
 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.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.tree.JCTree.*;
 
-import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.util.*;
+import javax.tools.JavaFileObject;
 
 import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Queue;
 import java.util.Set;
 import java.util.WeakHashMap;
 
-import javax.tools.JavaFileObject;
-
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 
-/** 
+/**
  * 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)
@@ -87,30 +87,30 @@
         infer = InferFactory.instance(context).getInfer();
         log = Log.instance(context);
         syms = Symtab.instance(context);
-        make = TreeMaker.instance(context);        
+        make = TreeMaker.instance(context);
         types = Types.instance(context);
     }
-    
+
     /**
      * 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<T extends JCTree> extends Type {
+    public class DeferredType extends Type {
 
-        public T tree;
+        public JCExpression tree;
         Env<AttrContext> env;
         AttrMode mode;
         SpeculativeCache speculativeCache;
-        
-        DeferredType(T tree, Env<AttrContext> env) {
+
+        DeferredType(JCExpression tree, Env<AttrContext> env) {
             super(DEFERRED, null);
             this.tree = tree;
             this.env = env.dup(tree, env.info.dup());
             this.speculativeCache = new SpeculativeCache();
         }
-        
+
         /**
          * A speculative cache is used to keep track of all overload resolution rounds
          * that triggered speculative attribution on a given deferred type. Each entry
@@ -119,7 +119,7 @@
          */
         class SpeculativeCache {
 
-            private Map<Symbol, List<Entry>> _map =
+            private Map<Symbol, List<Entry>> cache =
                     new WeakHashMap<Symbol, List<Entry>>();
 
             class Entry {
@@ -135,17 +135,17 @@
                     return this.phase == phase;
                 }
             }
-            
-            /** 
+
+            /**
              * Clone a speculative cache entry as a fresh entry associated
              * with a new method (this maybe required to fixup speculative cache
              * misses after Resolve.access())
              */
             void dupAllTo(Symbol from, Symbol to) {
-                Assert.check(_map.get(to) == null);
-                List<Entry> entries = _map.get(from);
+                Assert.check(cache.get(to) == null);
+                List<Entry> entries = cache.get(from);
                 if (entries != null) {
-                    _map.put(to, entries);
+                    cache.put(to, entries);
                 }
             }
 
@@ -154,28 +154,27 @@
              * and resolution phase
              */
             Entry get(Symbol msym, MethodResolutionPhase phase) {
-                List<Entry> entries = _map.get(msym);
+                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 = _map.get(msym);
+                List<Entry> entries = cache.get(msym);
                 if (entries == null) {
                     entries = List.nil();
                 }
-                _map.put(msym, entries =
-                        entries.prepend(new Entry(speculativeTree, phase)));
+                cache.put(msym, entries.prepend(new Entry(speculativeTree, phase)));
             }
         }
-        
+
         /**
          * Get the type that has been computed during a speculative attribution round
          */
@@ -183,7 +182,7 @@
             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
@@ -224,7 +223,7 @@
 
     /**
      * 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
@@ -239,7 +238,7 @@
          */
         CHECK;
     }
-    
+
     /**
      * Routine that performs speculative type-checking; the input AST node is
      * cloned (to avoid side-effects cause by Attr) and compiler state is
@@ -251,7 +250,7 @@
         Env<AttrContext> speculativeEnv = env.dup(newTree, env.info.dup(env.info.scope.dupUnshared()));
         speculativeEnv.info.scope.owner = env.info.scope.owner;
         Filter<JCDiagnostic> prevDeferDiagsFilter = log.deferredDiagFilter;
-        Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;                
+        Queue<JCDiagnostic> prevDeferredDiags = log.deferredDiagnostics;
         final JavaFileObject currentSource = log.currentSourceFile();
         try {
             log.deferredDiagnostics = new ListBuffer<JCDiagnostic>();
@@ -271,28 +270,28 @@
         } finally {
             unenterScanner.scan(newTree);
             log.deferredDiagFilter = prevDeferDiagsFilter;
-            log.deferredDiagnostics = prevDeferredDiags;                    
+            log.deferredDiagnostics = prevDeferredDiags;
         }
     }
-    
-    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);
-            if (csym.isLocal()) {
-                chk.undoLocalClassName(csym);
+    //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);
+                if (csym.isLocal()) {
+                    chk.undoLocalClassName(csym);
+                }
+                super.visitClassDef(tree);
             }
-            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
@@ -305,19 +304,19 @@
      * 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;
-        
+
         /** list of deferred attribution nodes to be processed */
         ArrayList<DeferredAttrNode> deferredAttrNodes = new ArrayList<DeferredAttrNode>();
 
@@ -327,15 +326,15 @@
             this.phase = phase;
             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) {
+        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)
@@ -344,7 +343,7 @@
          */
         void complete() {
             while (!deferredAttrNodes.isEmpty()) {
-                Set<Type> stuckVars = new HashSet<Type>();
+                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
@@ -360,28 +359,28 @@
                 if (!progress) {
                     //remove all variables that have already been instantiated
                     //from the list of stuck variables
-                    inferenceContext.solveAny(inferenceContext.freeVarsIn(List.from(stuckVars)));
+                    inferenceContext.solveAny(inferenceContext.freeVarsIn(List.from(stuckVars)), types, infer);
                     inferenceContext.notifyChange(types);
                 }
             }
         }
-        
+
         /**
          * Class representing a deferred attribution node. It keeps track of
          * a deferred type, along with the expected target type information.
          */
         class DeferredAttrNode implements Infer.InferenceContext.FreeTypeListener {
-            
-            /** deferred type */
-            DeferredType<?> dt;
-            
+
+            /** 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) {
+            DeferredAttrNode(DeferredType dt, ResultInfo resultInfo, List<Type> stuckVars) {
                 this.dt = dt;
                 this.resultInfo = resultInfo;
                 this.stuckVars = stuckVars;
@@ -396,13 +395,13 @@
                 resultInfo = resultInfo.dup(inferenceContext.asInstType(resultInfo.pt, types));
             }
 
-            /** 
+            /**
              * is this node stuck?
              */
             boolean isStuck() {
                 return stuckVars.nonEmpty();
             }
-            
+
             /**
              * Process a deferred attribution node.
              * Invariant: a stuck node cannot be processed.
@@ -415,12 +414,12 @@
             }
         }
     }
-    
+
     /** an empty deferred attribution context - all methods throw exceptions */
     final DeferredAttrContext emptyDeferredAttrContext =
             new DeferredAttrContext(null, null, null, null) {
                 @Override
-                void addDeferredAttrNode(DeferredType<?> dt, ResultInfo ri, List<Type> stuckVars) {
+                void addDeferredAttrNode(DeferredType dt, ResultInfo ri, List<Type> stuckVars) {
                     Assert.error("Empty deferred context!");
                 }
                 @Override
@@ -428,25 +427,25 @@
                     Assert.error("Empty deferred context!");
                 }
             };
-    
+
     /**
      * 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.
      */
-    abstract class DeferredTypeMap extends Type.Mapping {
-        
-        AttrMode mode;
+    class DeferredTypeMap extends Type.Mapping {
 
-        protected DeferredTypeMap(AttrMode mode) {
+        DeferredAttrContext deferredAttrContext;
+
+        protected DeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) {
             super(String.format("deferredTypeMap[%s]", mode));
-            this.mode = mode;
+            this.deferredAttrContext = new DeferredAttrContext(mode, msym, phase, infer.emptyContext);
         }
-        
-        protected boolean validState(DeferredType<?> dt) {
+
+        protected boolean validState(DeferredType dt) {
             return dt.mode != null &&
-                    mode.ordinal() <= dt.mode.ordinal();
+                    deferredAttrContext.mode.ordinal() <= dt.mode.ordinal();
         }
 
         @Override
@@ -454,88 +453,49 @@
             if (t.tag != DEFERRED) {
                 return t.map(this);
             } else {
-                DeferredType<?> dt = (DeferredType<?>)t;
+                DeferredType dt = (DeferredType)t;
                 Assert.check(validState(dt));
                 return typeOf(dt);
             }
         }
-        
-        protected abstract Type typeOf(DeferredType<?> dt);
-    }
-    
-    /**
-     * Specialized deferred mapping for SPECULATIVE deferred attribution rounds.
-     */
-    public class SpeculativeDeferredTypeMap extends DeferredTypeMap {
-        
-        Symbol msym;
-        MethodResolutionPhase phase;
 
-        public SpeculativeDeferredTypeMap(Symbol msym, MethodResolutionPhase phase) {
-            super(AttrMode.SPECULATIVE);
-            this.msym = msym;
-            this.phase = phase;
-        }
-
-        @Override
-        protected Type typeOf(DeferredType<?> dt) {
-            return dt.speculativeType(msym, phase);
+        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 deferred mapping for CHECK deferred attribution rounds.
+     * 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 CheckDeferredTypeMap extends DeferredTypeMap {
+    public class RecoveryDeferredTypeMap extends DeferredTypeMap {
 
-        public CheckDeferredTypeMap() {
-            super(AttrMode.CHECK);
+        public RecoveryDeferredTypeMap(AttrMode mode, Symbol msym, MethodResolutionPhase phase) {
+            super(mode, msym, phase);
         }
 
         @Override
-        protected Type typeOf(DeferredType<?> dt) {
-            return dt.tree.type;
-        }
-    }
-    
-    /**
-     * Specialized deferred mapping for SPECULATIVE deferred attribution rounds.
-     * 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
-     * SPECULATIVE 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 SpeculativeDeferredTypeMap {
-        
-        ResultInfo deferredRecoveryInfo;
-
-        public RecoveryDeferredTypeMap(final Symbol msym, final MethodResolutionPhase phase) {
-            super(msym, phase);
-            deferredRecoveryInfo = attr.new ResultInfo(attr.recoveryInfo.pkind,
-                    attr.recoveryInfo.pt, new Check.NestedCheckContext(attr.recoveryInfo.checkContext) {
-                        
-                        DeferredAttrContext deferredAttrContext = new DeferredAttrContext(mode, msym, phase, null);
-
-                        @Override
-                        public DeferredAttrContext deferredAttrContext() {
-                            return deferredAttrContext;
-                        }
-                        
-                    });
-        }
-
-        @Override
-        protected Type typeOf(DeferredType<?> dt) {
+        protected Type typeOf(DeferredType dt) {
             Type owntype = super.typeOf(dt);
             return owntype.tag == NONE ?
                         recover(dt) : owntype;
         }
 
         @Override
-        protected boolean validState(DeferredType<?> dt) {
+        protected boolean validState(DeferredType dt) {
             return true;
         }
-        
+
         /**
          * Synthesize a type for a deferred type that hasn't been previously
          * reduced to an ordinary type. Functional deferred types and conditionals
@@ -543,19 +503,31 @@
          * representation. Remaining deferred types are attributed using
          * a default expected type (j.l.Object).
          */
-        private Type recover(DeferredType<?> dt) {          
-            dt.check(deferredRecoveryInfo);
+        private Type recover(DeferredType dt) {
+            dt.check(attr.new RecoveryInfo(deferredAttrContext));
             switch (TreeInfo.skipParens(dt.tree).getTag()) {
                 case LAMBDA:
                 case REFERENCE:
                 case CONDEXPR:
+                    fixup(dt, dt);
+            }
+            return super.apply(dt);            
+        }
+        
+        void fixup(DeferredType dt, Type type) {
+            switch (deferredAttrContext.mode) {
+                case SPECULATIVE:
                     //fixup speculative cache
-                    dt.speculativeCache.get(msym, phase).speculativeTree.type = dt;
+                    dt.speculativeCache.get(deferredAttrContext.msym,
+                            deferredAttrContext.phase).speculativeTree.type = type;
+                    break;
+                case CHECK:
+                    //fixup tree type
+                    dt.tree.type = type;
             }
-            return super.apply(dt);
         }
     }
-   
+
     /**
      * Retrieves the list of inference variables that need to be inferred before
      * an AST node can be type-checked
@@ -582,7 +554,7 @@
         Type pt;
         Filter<JCTree> treeFilter;
         Infer.InferenceContext inferenceContext;
-        Set<Type> stuckVars = new HashSet<Type>();
+        Set<Type> stuckVars = new LinkedHashSet<Type>();
 
         final Filter<JCTree> argsFilter = new Filter<JCTree>() {
             public boolean accepts(JCTree t) {
@@ -615,7 +587,7 @@
             this.pt = resultInfo.pt;
             this.inferenceContext = resultInfo.checkContext.inferenceContext();
             this.treeFilter = argsFilter;
-        }        
+        }
 
         @Override
         public void scan(JCTree tree) {
@@ -632,7 +604,7 @@
                 if (inferenceContext.inferenceVars().contains(pt)) {
                     stuckVars.add(pt);
                 }
-                if (!types.isSam(pt.tsym)) {
+                if (!types.isFunctionalInterface(pt.tsym)) {
                     return;
                 }
                 Type descType = types.findDescriptorType(pt);
@@ -661,7 +633,7 @@
                 stuckVars.add(pt);
                 return;
             }
-            if (!types.isSam(pt.tsym)) {
+            if (!types.isFunctionalInterface(pt.tsym)) {
                 return;
             }
             Type descType = types.findDescriptorType(pt);
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -77,12 +77,12 @@
  *
  *  <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.
@@ -157,7 +157,7 @@
         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.annotations, sym.flags());
         return localEnv;
     }
 
@@ -312,7 +312,7 @@
                                 tree.packge);
                     if (addEnv || (tree0.packageAnnotations.isEmpty() &&
                                    tree.docComments != null &&
-                                   tree.docComments.get(tree) != null)) {
+                                   tree.docComments.hasComment(tree))) {
                         typeEnvs.put(tree.packge, topEnv);
                     }
                 }
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Oct 25 23:25:08 2012 +0100
@@ -43,15 +43,15 @@
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
-/** 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. Finally, effectively-final analysis determines that
- *  local variables accessed within the scope of a lambda expression are
- *  either final or effectively-final.
+/** 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
@@ -195,6 +195,7 @@
     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);
@@ -207,14 +208,14 @@
         new AliveAnalyzer().analyzeTree(env, make);
         new AssignAnalyzer().analyzeTree(env, make);
         new FlowAnalyzer().analyzeTree(env, make);
-        new EffectivelyFinalAnalyzer().analyzeTree(env, make);
+        new CaptureAnalyzer().analyzeTree(env, make);
     }
-    
+
     public void analyzeLambda(Env<AttrContext> env, JCLambda that, TreeMaker make, boolean speculative) {
         java.util.Queue<JCDiagnostic> prevDeferredDiagnostics = log.deferredDiagnostics;
         Filter<JCDiagnostic> prevDeferDiagsFilter = log.deferredDiagFilter;
         //we need to disable diagnostics temporarily; the problem is that if
-        //a lambda expression contains i.e. an unreachable statement, an error
+        //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
@@ -232,7 +233,7 @@
             }
         }
     }
-    
+
     /**
      * Definite assignment scan mode
      */
@@ -246,7 +247,7 @@
          * derive assertions within loop bodies
          */
         SPECULATIVE_LOOP("var.might.be.assigned.in.loop", true);
-        
+
         String errKey;
         boolean isFinal;
 
@@ -254,7 +255,7 @@
             this.errKey = errKey;
             this.isFinal = isFinal;
         }
-        
+
         boolean isFinal() {
             return isFinal;
         }
@@ -273,6 +274,7 @@
         Source source = Source.instance(context);
         allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis();
         allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis();
+        allowEffectivelyFinalInInnerClasses = source.allowEffectivelyFinalInInnerClasses();
     }
 
     /**
@@ -365,11 +367,12 @@
             return resolveJump(tree, oldPendingExits, JumpKind.BREAK);
         }
     }
-    
+
     /**
      * 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.
+     * The output of this analysis pass are used by other analyzers. This analyzer
+     * sets the 'finallyCanCompleteNormally' field in the JCTry class.
      */
     class AliveAnalyzer extends BaseAnalyzer<BaseAnalyzer.PendingExit> {
 
@@ -424,7 +427,7 @@
             Lint lintPrev = lint;
 
             pendingExits = new ListBuffer<PendingExit>();
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             try {
                 // process all the static initializers
@@ -460,7 +463,7 @@
             if (tree.body == null) return;
             Lint lintPrev = lint;
 
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             Assert.check(pendingExits.isEmpty());
 
@@ -486,7 +489,7 @@
         public void visitVarDef(JCVariableDecl tree) {
             if (tree.init != null) {
                 Lint lintPrev = lint;
-                lint = lint.augment(tree.sym.attributes_field);
+                lint = lint.augment(tree.sym.annotations);
                 try{
                     scan(tree.init);
                 } finally {
@@ -595,10 +598,10 @@
                     throw new AssertionError(tree);  // parser error
                 }
             }
-            
+
             scanStat(tree.body);
             boolean aliveEnd = alive;
-            
+
             for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
                 alive = true;
                 JCVariableDecl param = l.head.param;
@@ -656,7 +659,6 @@
 
         public void visitReturn(JCReturn tree) {
             scan(tree.expr);
-            // if not initial constructor, should markDead instead of recordExit
             recordExit(tree, new PendingExit(tree));
         }
 
@@ -684,7 +686,7 @@
                     tree.type.isErroneous()) {
                 return;
             }
-            
+
             ListBuffer<PendingExit> prevPending = pendingExits;
             boolean prevAlive = alive;
             try {
@@ -696,7 +698,7 @@
             finally {
                 pendingExits = prevPending;
                 alive = prevAlive;
-            }        
+            }
         }
 
         public void visitTopLevel(JCCompilationUnit tree) {
@@ -718,7 +720,7 @@
                 Flow.this.make = make;
                 pendingExits = new ListBuffer<PendingExit>();
                 alive = true;
-                scan(tree);
+                scan(env.tree);
             } finally {
                 pendingExits = null;
                 Flow.this.make = null;
@@ -760,8 +762,6 @@
                 super(tree);
                 this.thrown = thrown;
             }
-
-            void resolveJump() { /*do nothing*/ }
         }
 
         @Override
@@ -828,7 +828,7 @@
             }
             classDef = tree;
             thrown = List.nil();
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             try {
                 // process all the static initializers
@@ -908,7 +908,7 @@
             List<Type> mthrown = tree.sym.type.getThrownTypes();
             Lint lintPrev = lint;
 
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             Assert.check(pendingExits.isEmpty());
 
@@ -947,7 +947,7 @@
         public void visitVarDef(JCVariableDecl tree) {
             if (tree.init != null) {
                 Lint lintPrev = lint;
-                lint = lint.augment(tree.sym.attributes_field);
+                lint = lint.augment(tree.sym.annotations);
                 try{
                     scan(tree.init);
                 } finally {
@@ -1102,7 +1102,6 @@
                 thrown = List.nil();
                 ListBuffer<FlowPendingExit> exits = pendingExits;
                 pendingExits = prevPendingExits;
-                
                 scan(tree.finalizer);
                 if (!tree.finallyCanCompleteNormally) {
                     // discard exits and exceptions from try and finally
@@ -1171,7 +1170,6 @@
 
         public void visitReturn(JCReturn tree) {
             scan(tree.expr);
-            // if not initial constructor, should markDead instead of recordExit
             recordExit(tree, new FlowPendingExit(tree, null));
         }
 
@@ -1252,7 +1250,7 @@
                 pendingExits = prevPending;
                 caught = prevCaught;
                 thrown = prevThrown;
-            }        
+            }
         }
 
         public void visitTopLevel(JCCompilationUnit tree) {
@@ -1336,7 +1334,7 @@
         /** The next available variable sequence number.
          */
         int nextadr;
-        
+
         /** The first variable sequence number in a block that can return.
          */
         int returnadr;
@@ -1347,7 +1345,7 @@
 
         /** 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;
 
@@ -1392,11 +1390,7 @@
          *  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;
-            }
+            vars = ArrayUtils.ensureCapacity(vars, nextadr);
             if ((sym.flags() & FINAL) == 0) {
                 sym.flags_field |= EFFECTIVELY_FINAL;
             }
@@ -1409,7 +1403,7 @@
 
         /** Record an initialization of a trackable variable.
          */
-        void letInit(DiagnosticPosition pos, VarSymbol sym) {            
+        void letInit(DiagnosticPosition pos, VarSymbol sym) {
             if (sym.adr >= firstadr && trackable(sym)) {
                 if ((sym.flags() & EFFECTIVELY_FINAL) != 0) {
                     if (!uninits.isMember(sym.adr)) {
@@ -1565,7 +1559,7 @@
                 firstadr = nextadr;
             }
             classDef = tree;
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             try {
                 // define all the static fields
@@ -1633,7 +1627,7 @@
             int returnadrPrev = returnadr;
             Lint lintPrev = lint;
 
-            lint = lint.augment(tree.sym.attributes_field);
+            lint = lint.augment(tree.sym.annotations);
 
             Assert.check(pendingExits.isEmpty());
 
@@ -1685,7 +1679,7 @@
             if (track && tree.sym.owner.kind == MTH) newVar(tree.sym);
             if (tree.init != null) {
                 Lint lintPrev = lint;
-                lint = lint.augment(tree.sym.attributes_field);
+                lint = lint.augment(tree.sym.annotations);
                 try{
                     scanExpr(tree.init);
                     if (track) letInit(tree.pos(), tree.sym);
@@ -1742,8 +1736,8 @@
             pendingExits = new ListBuffer<AssignPendingExit>();
             int prevErrors = log.nerrors;
             Bits uninitsEntry = uninits.dup();
-            uninitsEntry.excludeFrom(nextadr);            
-            do {                
+            uninitsEntry.excludeFrom(nextadr);
+            do {
                 scanCond(tree.cond);
                 if (!flowKind.isFinal()) {
                     initsSkip = initsWhenFalse;
@@ -1761,7 +1755,7 @@
                 flowKind = FlowKind.SPECULATIVE_LOOP;
             } while (true);
             flowKind = prevFlowKind;
-            //a variable is DA/DU after a while, if it's DA/DU assuming the
+            //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 = initsSkip;
             uninits = uninitsSkip;
@@ -2041,7 +2035,6 @@
 
         public void visitReturn(JCReturn tree) {
             scanExpr(tree.expr);
-            // if not initial constructor, should markDead instead of recordExit
             recordExit(tree, new AssignPendingExit(tree, inits, uninits));
         }
 
@@ -2060,7 +2053,7 @@
             scanExprs(tree.args);
             scan(tree.def);
         }
-        
+
         @Override
         public void visitLambda(JCLambda tree) {
             Bits prevUninits = uninits;
@@ -2087,7 +2080,7 @@
                 uninits = prevUninits;
                 inits = prevInits;
                 pendingExits = prevPending;
-            }        
+            }
         }
 
         public void visitNewArray(JCNewArray tree) {
@@ -2192,7 +2185,6 @@
      * main method
      *************************************************************************/
 
-        
         /** Perform definite assignment/unassignment analysis on a tree.
          */
         public void analyzeTree(Env<AttrContext> env, TreeMaker make) {
@@ -2237,32 +2229,45 @@
             }
         }
     }
-    
+
     /**
      * 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 is either final or effectively final. As effectively
-     * final variables are marked as such during DA/DU, this pass must run after
+     * 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.
      */
-    class EffectivelyFinalAnalyzer extends BaseAnalyzer<BaseAnalyzer.PendingExit> {
-        
+    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() &&
-                    (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) == 0) {
-                reportEffectivelyFinalError(pos, sym);
+                    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)) {
@@ -2271,17 +2276,31 @@
                         sym.kind == VAR &&
                         sym.owner.kind == MTH &&
                         ((VarSymbol)sym).pos < currentTree.getStartPosition()) {
-                    reportEffectivelyFinalError(tree, sym);
+                    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
      *************************************************************************/
@@ -2315,7 +2334,7 @@
                 checkEffectivelyFinal(tree, (VarSymbol)tree.sym);
             }
         }
-        
+
         public void visitAssign(JCAssign tree) {
             JCTree lhs = TreeInfo.skipParens(tree.lhs);
             if (!(lhs instanceof JCIdent)) {
@@ -2342,7 +2361,7 @@
                     scan(tree.arg);
             }
         }
-        
+
         public void visitTopLevel(JCCompilationUnit tree) {
             // Do nothing for TopLevel since each class is visited individually
         }
@@ -2369,7 +2388,3 @@
         }
     }
 }
-
-
-
-        
--- a/src/share/classes/com/sun/tools/javac/comp/GraphInfer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/GraphInfer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -25,6 +25,7 @@
 
 package com.sun.tools.javac.comp;
 
+import com.sun.tools.javac.comp.Check.CheckContext;
 import com.sun.tools.javac.comp.GraphInfer.InferenceSolver.AcyclicInferenceGraph;
 import com.sun.tools.javac.comp.GraphInfer.InferenceSolver.AcyclicInferenceGraph.Node;
 import com.sun.tools.javac.tree.JCTree;
@@ -51,6 +52,7 @@
 
 import static com.sun.tools.javac.code.TypeTags.*;
 
+
 /** Helper class for type parameter inference, used by the attribution phase.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -62,13 +64,11 @@
 
     Check chk;
     Resolve rs;
-    DeferredAttr deferredAttr;
     Log log;
 
     protected GraphInfer(Context context) {
         super(context);
         rs = Resolve.instance(context);
-        deferredAttr = DeferredAttr.instance(context);
         log = Log.instance(context);
         chk = Check.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
@@ -78,8 +78,8 @@
     public Type instantiateMethod(Env<AttrContext> env,
                                   List<Type> tvars,
                                   MethodType mt,
+                                  Attr.ResultInfo resultInfo,
                                   Symbol msym,
-                                  Attr.ResultInfo resultInfo,
                                   List<Type> argtypes,
                                   boolean allowBoxing,
                                   boolean useVarargs,
@@ -89,8 +89,9 @@
         final GraphInferenceContext inferenceContext = new GraphInferenceContext(tvars);
         inferenceException.clear();
         try {
-            rs.checkRawArgumentsAcceptable(env, msym, resolveContext.attrMode(), inferenceContext, argtypes, mt.getParameterTypes(),
-                    allowBoxing, useVarargs, warn, new InferenceCheckHandler(inferenceContext));
+            rs.checkRawArgumentsAcceptable(env, msym, resolveContext.attrMode(), inferenceContext,
+                    argtypes, mt.getParameterTypes(), allowBoxing, useVarargs, warn,
+                    new InferenceCheckHandler(inferenceContext));
 
             if (resultInfo != null &&
                     !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
@@ -98,7 +99,7 @@
                 Type qtype1 = inferenceContext.asFree(mt.getReturnType(), types);
                 if (!types.isSubtypeNoCapture(qtype1,
                         qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to) &&
-                        !types.isSubtypeNoCapture(mt.getReturnType(), resultInfo.checkContext.inferenceContext().asFree(to, types))) {                
+                        !types.isSubtypeNoCapture(mt.getReturnType(), resultInfo.checkContext.inferenceContext().asFree(to, types))) {
                     throw inferenceException
                             .setMessage("infer.no.conforming.instance.exists",
                             inferenceContext.restvars(), mt.getReturnType(), to);
@@ -124,7 +125,7 @@
             return mt;
         } finally {
             inferenceContext.notifyChange(types);
-        }    
+        }
     }
     
     private void instantiateAsUninferredVars(List<Type> vars, InferenceContext inferenceContext) {
@@ -161,8 +162,62 @@
     /**
      * Check bounds and perform incorporation
      */
-    void checkWithinBounds(InferenceContext inferenceContext, Warner warn) throws InferenceException {
-        super.checkWithinBounds(inferenceContext, warn, incorporationSteps);
+    /** 
+     * Check that type parameters are within their bounds.
+     */
+    void checkWithinBounds(InferenceContext inferenceContext,
+                             Warner warn) throws InferenceException {
+        MultiUndetVarListener mlistener = new MultiUndetVarListener(inferenceContext.undetvars);
+        try {
+            while (true) {
+                mlistener.changed = false;
+                for (Type t : inferenceContext.undetvars) {
+                    UndetVar uv = (UndetVar)t;
+                    uv.substBounds(inferenceContext.inferenceVars(), inferenceContext.instTypes(), types);
+                    checkCompatibleUpperBounds(uv, inferenceContext.inferencevars);
+                    if (uv.inst != null) {
+                        Type inst = uv.inst;
+                        for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                            if (!types.isSubtypeUnchecked(inst, inferenceContext.asFree(u, types), warn)) {
+                                reportBoundError(uv, BoundErrorKind.UPPER);
+                            }
+                        }
+                        for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                            if (!types.isSubtypeUnchecked(inferenceContext.asFree(l, types), inst, warn)) {
+                                reportBoundError(uv, BoundErrorKind.LOWER);
+                            }
+                        }
+                        for (Type e : uv.getBounds(InferenceBound.EQ)) {
+                            if (!types.isSameType(inst, inferenceContext.asFree(e, types))) {
+                                reportBoundError(uv, BoundErrorKind.EQ);
+                            }
+                        }
+                    }
+                    //check eq bounds consistency
+                    for (Type e : uv.getBounds(InferenceBound.EQ)) {
+                        if (e.containsAny(inferenceContext.inferenceVars())) continue;
+                        for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                            if (!types.isSubtypeUnchecked(e, inferenceContext.asFree(u, types), warn)) {
+                                reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER);
+                            }
+                        }
+                        for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                            if (!types.isSubtypeUnchecked(inferenceContext.asFree(l, types), e, warn)) {
+                                reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER);
+                            }
+                        }
+                    }
+                    //bound incorporation
+                    for (IncorporationStep is : incorporationSteps) {
+                        is.apply(uv, inferenceContext);
+                    }
+                }
+                if (!mlistener.changed) break;
+            }
+        }
+        finally {
+            mlistener.detach();
+        }
     }
     //where
     IncorporationStep[] incorporationSteps = {
@@ -269,17 +324,16 @@
             }
         }
     };
- 
-    // <editor-fold desc="SAM type instantiation">
+
     @Override
-    public Type inferSAM(DiagnosticPosition pos, Type samType, List<Type> paramTypes, Check.CheckContext checkContext) {
-        if (types.capture(samType) == samType) {
+    public Type instantiateFunctionalInterface(DiagnosticPosition pos, Type funcInterface, List<Type> paramTypes, 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 wilddcards!)
-            return samType;
+            return funcInterface;
         } else {
-            List<Type> tvars = types.newInstances(samType.tsym.type.getTypeArguments());
-            Type formalSam = types.subst(samType.tsym.type, samType.tsym.type.getTypeArguments(), tvars);
+            List<Type> tvars = types.newInstances(funcInterface.tsym.type.getTypeArguments());
+            Type formalSam = types.subst(funcInterface.tsym.type, funcInterface.tsym.type.getTypeArguments(), tvars);
             GraphInferenceContext samInferenceContext = new GraphInferenceContext(tvars);
             if (paramTypes != null) {
                 //get constraints from explicit params (this is done by
@@ -287,32 +341,32 @@
                 //in the SAM descriptors)
                 List<Type> descParameterTypes = types.findDescriptorType(formalSam).getParameterTypes();
                 if (descParameterTypes.size() != paramTypes.size()) {
-                    checkContext.report(pos, diags.fragment("no.suitable.sam.inst", samType));
-                    return types.createErrorType(samType);
+                    checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+                    return types.createErrorType(funcInterface);
                 }
                 for (Type p : descParameterTypes) {
                     if (!types.isSameType(samInferenceContext.asFree(p, types), paramTypes.head)) {
-                        checkContext.report(pos, diags.fragment("no.suitable.sam.inst", samType));
-                        return types.createErrorType(samType);
+                        checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+                        return types.createErrorType(funcInterface);
                     }
                     paramTypes = paramTypes.tail;
                 }
             }
             //propagate constraints on wildcards
-            if (!types.isSubtypeUnchecked(samInferenceContext.asFree(formalSam, types), samType)) {
-                checkContext.report(pos, diags.fragment("no.suitable.sam.inst", samType));
-                return types.createErrorType(samType);
+            if (!types.isSubtypeUnchecked(samInferenceContext.asFree(formalSam, types), funcInterface)) {
+                checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+                return types.createErrorType(funcInterface);
             }
             
-            if (!checkContext.inferenceContext().free(samType)) {
+            if (!checkContext.inferenceContext().free(funcInterface)) {
                 //since there are no inference variable in the target type
                 //we can immediately solve the inference context
                 try {
                     samInferenceContext.solve();
                     return samInferenceContext.asInstType(formalSam, types);
                 } catch (InferenceException ex) {
-                    checkContext.report(pos, diags.fragment("no.suitable.sam.inst", samType));
-                    return types.createErrorType(samType);
+                    checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+                    return types.createErrorType(funcInterface);
                 }
             } else {
                 //if the target type depends on one or more inference variables
@@ -323,8 +377,8 @@
                         //we need to fix synthetic inference variables in argument position
                         samInferenceContext.solve(samInferenceContext.freeVarsIn(types.findDescriptorType(formalSam).getParameterTypes()));
                     } catch (InferenceException ex) {
-                        checkContext.report(pos, diags.fragment("no.suitable.sam.inst", samType));
-                        return types.createErrorType(samType);
+                        checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+                        return types.createErrorType(funcInterface);
                     }
                 }
                 if (samInferenceContext.restvars().nonEmpty()) {
@@ -432,7 +486,7 @@
         List<Type> saved_undet;
         
         GraphInferenceContext(List<Type> inferenceVars) {
-            super(inferenceVars, types);
+            super(inferenceVars, GraphInfer.this, true);
         }
         
         /**
@@ -442,7 +496,7 @@
             ListBuffer<Type> buf = ListBuffer.lb();
             for (Type t : undetvars) {
                 UndetVar uv = (UndetVar)t;
-                UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, true, types);
+                UndetVar uv2 = new UndetVar((TypeVar)uv.qtype, types, true);
                 for (InferenceBound ib : InferenceBound.values()) {
                     for (Type b : uv.getBounds(ib)) {
                         uv2.addBound(ib, b, types);
@@ -467,6 +521,7 @@
          * Copy variable in this inference context to the given context
          */
         void dupTo(InferenceContext that) {
+            that.inferencevars = that.inferencevars.appendList(inferencevars);
             that.undetvars = that.undetvars.appendList(undetvars);
             that.freeTypeListeners.putAll(freeTypeListeners);
         }
@@ -499,10 +554,10 @@
         }
 
         @Override
-        public void solveAny(final List<Type> stuckvars) {
-            solve(new BestLeafSolver(stuckvars) {
+        public void solveAny(List<Type> varsToSolve, final Types types, Infer infer) {
+            solve(new BestLeafSolver(varsToSolve) {
                 public boolean done() {
-                    return asInstTypes(stuckvars, types) != stuckvars;
+                    return asInstTypes(varsToSolve, types) != varsToSolve;
                 }
             });
         }
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -35,6 +35,7 @@
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.code.Type.UndetVar.InferenceBound;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
 import com.sun.tools.javac.comp.Resolve.InapplicableMethodException;
 
 import java.util.HashMap;
@@ -52,26 +53,27 @@
  */
 public abstract class Infer {
 
-    DeferredAttr deferredAttr;
     Symtab syms;
     Types types;    
     JCDiagnostic.Factory diags;
 
     protected Infer(Context context) {
-        deferredAttr = DeferredAttr.instance(context);
         syms = Symtab.instance(context);
         types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
         inferenceException = new InferenceException(diags);
     }
+    
+    /** A value for prototypes that admit any type, including polymorphic ones. */
+    public static final Type anyPoly = new Type(NONE, null);
 
-    /**
-     * This exception class is design to store a list of diagnostics corresponding
-     * to inference errors that can arise during a method applicability check.
-     */
+   /**
+    * 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;
-        
+
         List<JCDiagnostic> messages = List.nil();
 
         InferenceException(JCDiagnostic.Factory diags) {
@@ -88,7 +90,7 @@
         public JCDiagnostic getDiagnostic() {
             return messages.head;
         }
-        
+
         void clear() {
             messages = List.nil();
         }
@@ -104,21 +106,29 @@
     public abstract Type instantiateMethod(Env<AttrContext> env,
                                   List<Type> tvars,
                                   MethodType mt,
+                                  Attr.ResultInfo resultInfo,
                                   Symbol msym,
-                                  Attr.ResultInfo resultInfo,
                                   List<Type> argtypes,
                                   boolean allowBoxing,
                                   boolean useVarargs,
                                   Resolve.MethodResolutionContext resolveContext,
                                   Warner warn) throws InferenceException;
-    
+
     /**
      * 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 abstract Type inferSAM(DiagnosticPosition pos, Type samType, List<Type> paramTypes, Check.CheckContext checkContext);
+    public abstract Type instantiateFunctionalInterface(DiagnosticPosition pos, Type funcInterface,
+            List<Type> paramTypes, Check.CheckContext checkContext);
+
+    protected Filter<Type> boundFilter = new Filter<Type>() {
+        @Override
+        public boolean accepts(Type t) {
+            return !t.isErroneous() && t.tag != BOT;
+        }
+    };
 
     /** 
      * Inference check handler - used to report inference error during method
@@ -135,12 +145,12 @@
         public InapplicableMethodException arityMismatch() {
             return inferenceException.setMessage("infer.arg.length.mismatch", inferenceContext.inferenceVars());
         }
-        public InapplicableMethodException argumentMismatch(boolean varargs, JCDiagnostic diag) {
+        public InapplicableMethodException argumentMismatch(boolean varargs, JCDiagnostic details) {
             String key = varargs ?
                     "infer.varargs.argument.mismatch" :
                     "infer.no.conforming.assignment.exists";
             return inferenceException.setMessage(key,
-                    inferenceContext.inferenceVars(), diag);
+                    inferenceContext.inferenceVars(), details);
         }
         public InapplicableMethodException inaccessibleVarargs(Symbol location, Type expected) {
             return inferenceException.setMessage("inaccessible.varargs.type",
@@ -164,59 +174,67 @@
      * Check that type parameters are within their bounds.
      */
     void checkWithinBounds(InferenceContext inferenceContext,
-                             Warner warn, IncorporationStep... incorporationSteps) throws InferenceException {
-        MultiUndetVarListener mlistener = new MultiUndetVarListener(inferenceContext.undetvars);
-        try {
-            while (true) {
-                mlistener.changed = false;
-                for (Type t : inferenceContext.undetvars) {
-                    UndetVar uv = (UndetVar)t;
-                    uv.substBounds(inferenceContext.inferenceVars(), inferenceContext.insttypes(), types);
-                    checkCompatibleUpperBounds(uv, inferenceContext);
-                    if (uv.inst != null) {
-                        Type inst = uv.inst;
-                        for (Type u : uv.getBounds(InferenceBound.UPPER)) {
-                            if (!types.isSubtypeUnchecked(inst, inferenceContext.asFree(u, types), warn)) {
-                                reportBoundError(uv, BoundErrorKind.UPPER);
-                            }
-                        }
-                        for (Type l : uv.getBounds(InferenceBound.LOWER)) {
-                            if (!types.isSubtypeUnchecked(inferenceContext.asFree(l, types), inst, warn)) {
-                                reportBoundError(uv, BoundErrorKind.LOWER);
-                            }
-                        }
-                        for (Type e : uv.getBounds(InferenceBound.EQ)) {
-                            if (!types.isSameType(inst, inferenceContext.asFree(e, types))) {
-                                reportBoundError(uv, BoundErrorKind.EQ);
-                            }
-                        }
+                           Warner warn, IncorporationStep... incorporationSteps) throws InferenceException {
+        //step 1 - check compatibility of instantiated type w.r.t. initial bounds
+        for (Type t : inferenceContext.undetvars) {
+            UndetVar uv = (UndetVar)t;
+            uv.substBounds(inferenceContext.inferenceVars(), inferenceContext.instTypes(), types);
+            checkCompatibleUpperBounds(uv, inferenceContext.inferenceVars());
+            if (!inferenceContext.restvars().contains(uv.qtype)) {
+                Type inst = inferenceContext.asInstType(t, types);
+                for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                    if (!types.isSubtypeUnchecked(inst, inferenceContext.asFree(u, types), warn)) {
+                        reportBoundError(uv, BoundErrorKind.UPPER);
                     }
-                    //check eq bounds consistency
-                    for (Type e : uv.getBounds(InferenceBound.EQ)) {
-                        if (e.containsAny(inferenceContext.inferenceVars())) continue;
-                        for (Type u : uv.getBounds(InferenceBound.UPPER)) {
-                            if (!types.isSubtypeUnchecked(e, inferenceContext.asFree(u, types), warn)) {
-                                reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER);
-                            }
-                        }
-                        for (Type l : uv.getBounds(InferenceBound.LOWER)) {
-                            if (!types.isSubtypeUnchecked(inferenceContext.asFree(l, types), e, warn)) {
-                                reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER);
-                            }
-                        }
+                }
+                for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                    Assert.check(!inferenceContext.free(l));
+                    if (!types.isSubtypeUnchecked(l, inst, warn)) {
+                        reportBoundError(uv, BoundErrorKind.LOWER);
                     }
-                    //bound incorporation
-                    for (IncorporationStep is : incorporationSteps) {
-                        is.apply(uv, inferenceContext);
+                }
+                for (Type e : uv.getBounds(InferenceBound.EQ)) {
+                    Assert.check(!inferenceContext.free(e));
+                    if (!types.isSameType(inst, e)) {
+                        reportBoundError(uv, BoundErrorKind.EQ);
                     }
                 }
-                if (!mlistener.changed) break;
             }
         }
-        finally {
-            mlistener.detach();
+
+        //step 2 - check that eq bounds are consistent w.r.t. eq/lower bounds
+        for (Type t : inferenceContext.undetvars) {
+            UndetVar uv = (UndetVar)t;
+            //check eq bounds consistency
+            Type eq = null;
+            for (Type e : uv.getBounds(InferenceBound.EQ)) {
+                Assert.check(!inferenceContext.free(e));
+                if (eq != null && !types.isSameType(e, eq)) {
+                    reportBoundError(uv, BoundErrorKind.EQ);
+                }
+                eq = e;
+                for (Type l : uv.getBounds(InferenceBound.LOWER)) {
+                    Assert.check(!inferenceContext.free(l));
+                    if (!types.isSubtypeUnchecked(l, e, warn)) {
+                        reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER);
+                    }
+                }
+                for (Type u : uv.getBounds(InferenceBound.UPPER)) {
+                    if (inferenceContext.free(u)) continue;
+                    if (!types.isSubtypeUnchecked(e, u, warn)) {
+                        reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER);
+                    }
+                }
+            }
+        }
+        //step 3 - bound incorporation
+        for (Type t : inferenceContext.undetvars) {
+            for (IncorporationStep is : incorporationSteps) {
+                is.apply((UndetVar)t, inferenceContext);
+            }
         }
     }
+
     //where
         /**
          * This listener keeps track of changes on a group of inference variable
@@ -249,21 +267,26 @@
             }                
         };
 
-    void checkCompatibleUpperBounds(UndetVar uv, InferenceContext inferenceContext) {
+        void checkCompatibleUpperBounds(UndetVar uv, List<Type> tvars) {
         // VGJ: sort of inlined maximizeInst() below.  Adding
         // bounds can cause lobounds that are above hibounds.
-        List<Type> hibounds = Type.filter(uv.getBounds(InferenceBound.UPPER), new BoundFilter(inferenceContext));
+        ListBuffer<Type> hiboundsNoVars = ListBuffer.lb();
+        for (Type t : Type.filter(uv.getBounds(InferenceBound.UPPER), boundFilter)) {
+            if (!t.containsAny(tvars)) {
+                hiboundsNoVars.append(t);
+            }
+        }
+        List<Type> hibounds = hiboundsNoVars.toList();
         Type hb = null;
         if (hibounds.isEmpty())
             hb = syms.objectType;
         else if (hibounds.tail.isEmpty())
             hb = hibounds.head;
         else
-           hb = types.glb(hibounds);
+            hb = types.glb(hibounds);
         if (hb == null || hb.isErroneous())
             reportBoundError(uv, BoundErrorKind.BAD_UPPER);
-    }
-    //where
+    }    //where
             protected class BoundFilter implements Filter<Type> {
                 
                 InferenceContext inferenceContext;
@@ -340,7 +363,8 @@
     Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env,
                                             MethodSymbol spMethod,  // sig. poly. method or null if none
                                             Resolve.MethodResolutionContext resolveContext,
-                                            List<Type> argtypes) {
+                                            List<Type> argtypes,
+                                            Resolve rs) {
         final Type restype;
 
         //The return type for a polymorphic signature call is computed from
@@ -369,7 +393,7 @@
                 restype = syms.objectType;
         }
 
-        List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step));
+        List<Type> paramtypes = Type.map(argtypes, new ImplicitArgType(spMethod, resolveContext.step, rs));
         List<Type> exType = spMethod != null ?
             spMethod.getThrownTypes() :
             List.of(syms.throwableType); // make it throw all exceptions
@@ -381,10 +405,10 @@
         return mtype;
     }
     //where
-        class ImplicitArgType extends DeferredAttr.SpeculativeDeferredTypeMap {
+        class ImplicitArgType extends DeferredAttr.DeferredTypeMap {
 
-            public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase) {
-                deferredAttr.super(msym, phase);
+            public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase, Resolve rs) {
+                rs.deferredAttr.super(AttrMode.SPECULATIVE, msym, phase);
             }
 
             public Type apply(Type t) {
@@ -396,9 +420,26 @@
                 return t;
             }
         }
-    // </editor-fold>
+
+    /**
+     * Mapping that turns inference variables into undet vars
+     * (used by inference context)
+     */
+    class FromTypeVarFun extends Mapping {
+
+        boolean includeBounds;
 
-    // <editor-fold defaultstate="collapsed" desc="Inference context">
+        FromTypeVarFun(boolean includeBounds) {
+            super("fromTypeVarFunWithBounds");
+            this.includeBounds = includeBounds;
+        }
+
+        public Type apply(Type t) {
+            if (t.tag == TYPEVAR) return new UndetVar((TypeVar)t, types, includeBounds);
+            else return t.map(this);
+        }
+    };
+
     /**
      * An inference context keeps track of the set of variables that are free
      * in the current context. It provides utility methods for opening/closing
@@ -413,28 +454,25 @@
         * Single-method-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);
         }
-        
+
         /** 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>>();
-        
-        public InferenceContext(List<Type> inferenceVars, final Types types) {
-            this(inferenceVars, types, true);
-        }
-        
-        public InferenceContext(List<Type> inferenceVars, final Types types, final boolean includeBounds) {
-            this.undetvars = Type.map(inferenceVars, new Mapping("fromTypeVarFun") {
-                public Type apply(Type t) {
-                    if (t.tag == TYPEVAR) return new UndetVar((TypeVar)t, includeBounds, types);
-                    else return t.map(this);
-                }
-            });
+
+        List<FreeTypeListener> freetypeListeners = List.nil();
+
+        public InferenceContext(List<Type> inferencevars, Infer infer, boolean includeBounds) {
+            this.undetvars = Type.map(inferencevars, infer.new FromTypeVarFun(includeBounds));
+            this.inferencevars = inferencevars;
         }
 
         /**
@@ -442,24 +480,7 @@
          * inference context
          */
         List<Type> inferenceVars() {
-            ListBuffer<Type> tvars = ListBuffer.lb();
-            for (Type uv : undetvars) {
-                tvars.append(((UndetVar)uv).qtype);
-            }
-            return tvars.toList();
-        }
-        
-        List<Type> insttypes() {
-            ListBuffer<Type> insttypes = ListBuffer.lb();
-            for (Type t : undetvars) {
-                UndetVar uv = (UndetVar)t;
-                if (uv.inst != null) {
-                    insttypes.append(uv.inst);
-                } else {
-                    insttypes.append(uv.qtype);
-                }
-            }
-            return insttypes.toList();
+            return inferencevars;
         }
 
         /**
@@ -469,7 +490,7 @@
         List<Type> restvars() {
             List<Type> undetvars = this.undetvars;
             ListBuffer<Type> restvars = ListBuffer.lb();
-            for (Type t : insttypes()) {
+            for (Type t : instTypes()) {
                 UndetVar uv = (UndetVar)undetvars.head;
                 if (uv.qtype == t) {
                     restvars.append(t);
@@ -478,21 +499,24 @@
             }
             return restvars.toList();
         }
-        
+
         /**
          * is this type free?
          */
         final boolean free(Type t) {
-            return t.containsAny(inferenceVars());
+            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()) {
@@ -502,7 +526,7 @@
             }
             return buf.toList();
         }
-        
+
         final List<Type> freeVarsIn(List<Type> ts) {
             ListBuffer<Type> buf = ListBuffer.lb();
             for (Type t : ts) {
@@ -523,9 +547,9 @@
          * of inference constraints).
          */
         final Type asFree(Type t, Types types) {
-            return types.subst(t, inferenceVars(), undetvars);
+            return types.subst(t, inferencevars, undetvars);
         }
-        
+
         final List<Type> asFree(List<Type> ts, Types types) {
             ListBuffer<Type> buf = ListBuffer.lb();
             for (Type t : ts) {
@@ -533,16 +557,25 @@
             }
             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, Types types) {
-            return types.subst(t, inferenceVars(), insttypes());
+            return types.subst(t, inferencevars, instTypes());
         }
-        
+
         List<Type> asInstTypes(List<Type> ts, Types types) {
             ListBuffer<Type> buf = ListBuffer.lb();
             boolean changed = false;
@@ -574,7 +607,9 @@
                         entry.getKey().typesInferred(this);
                         freeTypeListeners.remove(entry.getKey());
                     } catch (InferenceException ex) {
-                        thrownEx = ex;
+                        if (thrownEx == null) {
+                            thrownEx = ex;
+                        }
                     }
                 }
             }
@@ -585,12 +620,12 @@
             }
         }
         
-        abstract void solveAny(List<Type> stuckvars);
+        abstract void solveAny(List<Type> varsToSolve, Types types, Infer infer);
     }
     
-    final InferenceContext emptyContext = new InferenceContext(List.<Type>nil(), types) {
+    final InferenceContext emptyContext = new InferenceContext(List.<Type>nil(), this, false) {
         @Override
-        void solveAny(List<Type> stuckvars) {
+        void solveAny(List<Type> varsToSolve, Types types, Infer infer) {
             Assert.error();
         }
     };
--- a/src/share/classes/com/sun/tools/javac/comp/InferFactory.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/InferFactory.java	Thu Oct 25 23:25:08 2012 +0100
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.comp;
 
 import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Options;
 
@@ -61,6 +62,7 @@
     }
     
     public Infer getInfer() {
+        Assert.checkNonNull(infer);
         return infer;
     }
 }
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToInnerClass.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToInnerClass.java	Thu Oct 25 23:25:08 2012 +0100
@@ -369,7 +369,6 @@
                 break;
             case SUPER: break;
             case UNBOUND:
-            case UNBOUND_INNER:
                 rec = make.Ident(params.toList().head.sym);
                 break;
             default:
--- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Thu Oct 25 23:25:08 2012 +0100
@@ -175,7 +175,7 @@
         List<JCExpression> indy_args = translate(syntheticInits.toList(), localContext.prev);
 
         //build a sam instance using an indy call to the meta-factory
-        int refKind = Pool.MemberReference.methodRefKind(sym.isStatic(), sym.enclClass().isInterface());
+        int refKind = referenceKind(sym);
                 
         //convert to an invokedynamic call 
         result = makeMetaFactoryIndyCall(tree, tree.targetType, refKind, sym, indy_args);
@@ -227,7 +227,6 @@
             case STATIC_EVAL:       /** Expr # staticMethod */
             case UNBOUND:           /** Type # instMethod */
             case STATIC:            /** Type # staticMethod */
-            case UNBOUND_INNER:     /** Outer.Inner # new */
             case TOPLEVEL:          /** Top level # new */
                 init = null;
                 break;
@@ -343,7 +342,6 @@
                         recType = tree.getQualifierExpression().type;
                         break;
                     case UNBOUND:
-                    case UNBOUND_INNER:
                         recType = samPTypes.head;
                         samPTypes = samPTypes.tail;
                         break;
@@ -439,7 +437,6 @@
             JCExpression encl = null;
             switch (tree.kind) {
                 case UNBOUND:
-                case UNBOUND_INNER:
                 case IMPLICIT_INNER:
                     encl = make.Ident(params.first());
             }
@@ -484,8 +481,8 @@
         //determine the static bsm args
         Type mtype = makeFunctionalDescriptorType(targetType, true);
         List<Object> staticArgs = List.<Object>of(
-                new Pool.MemberReference(ClassFile.REF_invokeInterface, types.findDescriptorSymbol(targetType.tsym)),
-                new Pool.MemberReference(refKind, refSym),
+                new Pool.MethodHandle(ClassFile.REF_invokeInterface, types.findDescriptorSymbol(targetType.tsym)),
+                new Pool.MethodHandle(refKind, refSym),
                 new MethodType(mtype.getParameterTypes(),
                         mtype.getReturnType(),
                         mtype.getThrownTypes(),
@@ -563,7 +560,7 @@
             return syms.doubleType;
         } else if (arg instanceof String) {
             return syms.stringType;
-        } else if (arg instanceof Pool.MemberReference) {
+        } else if (arg instanceof Pool.MethodHandle) {
             return syms.methodHandleType;
         } else if (arg instanceof MethodType) {
             return syms.methodTypeType;
@@ -572,6 +569,26 @@
             return null;
         }
     }
+    
+    /**
+     * Get the opcode associated with this method reference
+     */
+    int referenceKind(Symbol refSym) {
+        if (refSym.isConstructor()) {
+            if (!refSym.isConstructor())
+                return ClassFile.REF_invokeSpecial;
+            else {
+                return ClassFile.REF_newInvokeSpecial;
+            }
+        } else {
+            if (refSym.isStatic())
+                return ClassFile.REF_invokeStatic;
+            else if (refSym.enclClass().isInterface())
+                return ClassFile.REF_invokeInterface;
+            else
+                return ClassFile.REF_invokeVirtual;
+        }
+    }
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="Lambda/reference analyzer">\
@@ -743,18 +760,13 @@
                                               lambdaName().append(names.fromString("$bridge")), null,
                                               owner.enclClass())
                         : null;
-            }
+            }            
 
             /**
              * Get the opcode associated with this method reference
              */
             int referenceKind() {
-                Symbol refSym = needsBridge() ? bridgeSym : tree.sym;
-                if (refSym.isConstructor()) {
-                    return Pool.MemberReference.specialRefKind(refSym.isConstructor());
-                } else {
-                    return Pool.MemberReference.methodRefKind(refSym.isStatic(), refSym.enclClass().isInterface());
-                }
+                return LambdaToMethod.this.referenceKind(needsBridge() ? bridgeSym : tree.sym);
             }
 
             protected boolean needsVarArgsConversion() {
--- a/src/share/classes/com/sun/tools/javac/comp/LegacyInfer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/LegacyInfer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -115,14 +115,15 @@
      * constraints. If no instantiation exists, or if several incomparable
      * best instantiations exist throw a NoInstanceException.
      */
-    private void instantiateUninferred(DiagnosticPosition pos,
+    public void instantiateUninferred(DiagnosticPosition pos,
             InferenceContext inferenceContext,
             MethodType mtype,
-            Attr.ResultInfo resultInfo) throws InferenceException {
+            Attr.ResultInfo resultInfo,
+            Warner warn) throws InferenceException {
         Type to = resultInfo.pt;
         if (to.tag == NONE || resultInfo.checkContext.inferenceContext().free(resultInfo.pt)) {
             to = mtype.getReturnType().tag <= VOID ?
-            mtype.getReturnType() : syms.objectType;
+                    mtype.getReturnType() : syms.objectType;
         }
         Type qtype1 = inferenceContext.asFree(mtype.getReturnType(), types);
         if (!types.isSubtype(qtype1,
@@ -131,13 +132,12 @@
                     .setMessage("infer.no.conforming.instance.exists",
                     inferenceContext.restvars(), mtype.getReturnType(), to);
         }
-        
+
         while (true) {
             boolean stuck = true;
             for (Type t : inferenceContext.undetvars) {
                 UndetVar uv = (UndetVar)t;
-                if (uv.inst == null &&
-                        (uv.getBounds(InferenceBound.EQ).nonEmpty() ||
+                if (uv.inst == null && (uv.getBounds(InferenceBound.EQ).nonEmpty() ||
                         !inferenceContext.free(uv.getBounds(InferenceBound.UPPER)))) {
                     maximizeInst((UndetVar)t, inferenceContext);
                     stuck = false;
@@ -156,7 +156,7 @@
                 //variables in remaining upper bounds and continue
                 for (Type t : inferenceContext.undetvars) {
                     UndetVar uv = (UndetVar)t;
-                    uv.substBounds(inferenceContext.inferenceVars(), inferenceContext.insttypes(), types);
+                    uv.substBounds(inferenceContext.inferenceVars(), inferenceContext.instTypes(), types);
                 }
             }
         }
@@ -195,8 +195,8 @@
     public Type instantiateMethod(Env<AttrContext> env,
                                   List<Type> tvars,
                                   MethodType mt,
+                                  Attr.ResultInfo resultInfo,
                                   Symbol msym,
-                                  Attr.ResultInfo resultInfo,
                                   List<Type> argtypes,
                                   boolean allowBoxing,
                                   boolean useVarargs,
@@ -205,9 +205,11 @@
         //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
         final InferenceContext inferenceContext = new LegacyInferenceContext(tvars, true);
         inferenceException.clear();
+
         try {
-            rs.checkRawArgumentsAcceptable(env, msym, resultInfo != null ? DeferredAttr.AttrMode.CHECK : DeferredAttr.AttrMode.SPECULATIVE, inferenceContext, argtypes, mt.getParameterTypes(),
-                    allowBoxing, useVarargs, warn, new InferenceCheckHandler(inferenceContext));
+            rs.checkRawArgumentsAcceptable(env, msym, resolveContext.attrMode(), inferenceContext,
+                    argtypes, mt.getParameterTypes(), allowBoxing, useVarargs, warn,
+                    new InferenceCheckHandler(inferenceContext));
 
             // minimize as yet undetermined type variables
             for (Type t : inferenceContext.undetvars) {
@@ -218,12 +220,11 @@
 
             mt = (MethodType)inferenceContext.asInstType(mt, types);
 
-            List<Type> restvars = inferenceContext.restvars(); 
+            List<Type> restvars = inferenceContext.restvars();
 
-            if (!restvars.isEmpty() && resultInfo != null &&
-                    !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
-                if (resultInfo != null) {
-                    instantiateUninferred(env.tree.pos(), inferenceContext, mt, resultInfo);
+            if (!restvars.isEmpty()) {
+                if (resultInfo != null && !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) {
+                    instantiateUninferred(env.tree.pos(), inferenceContext, mt, resultInfo, warn);
                     checkWithinBounds(inferenceContext, warn);
                     mt = (MethodType)inferenceContext.asInstType(mt, types);
                     if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
@@ -231,55 +232,57 @@
                     }
                 }
             }
-            inferenceContext.notifyChange(types);
+
             // return instantiated version of method type
             return mt;
-        } finally {            
+        } finally {
             inferenceContext.notifyChange(types);
         }
     }
     
     @Override
-    public Type inferSAM(DiagnosticPosition pos, Type samType, List<Type> paramTypes, Check.CheckContext checkContext) {
-        if (types.capture(samType) == samType) {
+    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 wilddcards!)
-            return samType;
+            //(this means the target contains no wildcards!)
+            return funcInterface;
         } else {
-            Type formalSam = samType.tsym.type;
-            InferenceContext samInferenceContext = new LegacyInferenceContext(samType.tsym.type.getTypeArguments(), false);
+            Type formalInterface = funcInterface.tsym.type;
+            InferenceContext funcInterfaceContext =
+                    new LegacyInferenceContext(funcInterface.tsym.type.getTypeArguments(), false);
             if (paramTypes != null) {
                 //get constraints from explicit params (this is done by
                 //checking that explicit param types are equal to the ones
-                //in the SAM descriptors)
-                List<Type> descParameterTypes = types.findDescriptorType(formalSam).getParameterTypes();
+                //in the functional interface descriptors)
+                List<Type> descParameterTypes = types.findDescriptorType(formalInterface).getParameterTypes();
                 if (descParameterTypes.size() != paramTypes.size()) {
-                    checkContext.report(pos, diags.fragment("no.suitable.sam.inst", samType));
-                    return types.createErrorType(samType);
+                    checkContext.report(pos, diags.fragment("incompatible.arg.types.in.lambda"));
+                    return types.createErrorType(funcInterface);
                 }
                 for (Type p : descParameterTypes) {
-                    if (!types.isSameType(samInferenceContext.asFree(p, types), paramTypes.head)) {
-                        checkContext.report(pos, diags.fragment("no.suitable.sam.inst", samType));
-                        return types.createErrorType(samType);
+                    if (!types.isSameType(funcInterfaceContext.asFree(p, types), paramTypes.head)) {
+                        checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
+                        return types.createErrorType(funcInterface);
                     }
                     paramTypes = paramTypes.tail;
                 }
-                for (Type t : samInferenceContext.undetvars) {
+                for (Type t : funcInterfaceContext.undetvars) {
                     UndetVar uv = (UndetVar)t;
-                    minimizeInst(uv, checkContext.inferenceContext());
+                    minimizeInst(uv, funcInterfaceContext);
                     if (uv.inst == null &&
-                            Type.filter(uv.getBounds(InferenceBound.UPPER), new BoundFilter(checkContext.inferenceContext())).nonEmpty()) {
-                        maximizeInst(uv, samInferenceContext);
+                            Type.filter(uv.getBounds(InferenceBound.UPPER), boundFilter).nonEmpty()) {
+                        maximizeInst(uv, funcInterfaceContext);
                     }
                 }
-                
-                formalSam = samInferenceContext.asInstType(formalSam, types);
+
+                formalInterface = funcInterfaceContext.asInstType(formalInterface, types);
             }
             ListBuffer<Type> typeargs = ListBuffer.lb();
-            List<Type> actualTypeargs = samType.getTypeArguments();
-            //for remaining uninferred type-vars in the SAM type,
+            List<Type> actualTypeargs = funcInterface.getTypeArguments();
+            //for remaining uninferred type-vars in the functional interface type,
             //simply replace the wildcards with its bound
-            for (Type t : formalSam.getTypeArguments()) {
+            for (Type t : formalInterface.getTypeArguments()) {
                 if (actualTypeargs.head.tag == WILDCARD) {
                     WildcardType wt = (WildcardType)actualTypeargs.head;
                     typeargs.append(wt.type);
@@ -288,12 +291,12 @@
                 }
                 actualTypeargs = actualTypeargs.tail;
             }
-            Type owntype = types.subst(formalSam, samInferenceContext.inferenceVars(), typeargs.toList());
+            Type owntype = types.subst(formalInterface, funcInterfaceContext.inferenceVars(), typeargs.toList());
             if (!chk.checkValidGenericType(owntype)) {
-                //if the inferred SAM 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.sam.inst", samType));
-                return types.createErrorType(samType);
+                //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 types.createErrorType(funcInterface);
             }
             return owntype;
         }
@@ -306,13 +309,13 @@
     class LegacyInferenceContext extends InferenceContext {
 
         public LegacyInferenceContext(List<Type> inferenceVars, boolean includeBounds) {
-            super(inferenceVars, types, includeBounds);
+            super(inferenceVars, LegacyInfer.this, includeBounds);
         }
         
         @Override
-        void solveAny(List<Type> varsToSolve) {
+        void solveAny(List<Type> varsToSolve, Types types, Infer infer) {
             boolean progress = false;
-            for (Type t : varsToSolve) {                
+            for (Type t : varsToSolve) {
                 UndetVar uv = (UndetVar)asFree(t, types);
                 if (uv.inst == null) {
                     minimizeInst(uv, this);
@@ -322,7 +325,7 @@
                 }
             }
             if (!progress) {
-                throw inferenceException.setMessage("cyclic.lambda.inference");
+                throw infer.inferenceException.setMessage("cyclic.inference", varsToSolve);
             }
         }
     }
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Oct 25 23:25:08 2012 +0100
@@ -40,7 +40,7 @@
 import com.sun.tools.javac.code.Type.*;
 
 import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.BLOCK;
@@ -1449,7 +1449,7 @@
             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.
      */
@@ -1606,6 +1606,11 @@
     }
 
     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,
@@ -1618,7 +1623,7 @@
     }
 
     /** 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.
      */
@@ -1656,7 +1661,7 @@
     }
 
     /** 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
@@ -1708,7 +1713,7 @@
         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) {
@@ -1725,7 +1730,7 @@
                     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;
@@ -2252,7 +2257,7 @@
                                 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.annotations.setAttributes(tree.packge.annotations);
             ClassType ctype = (ClassType) c.type;
             ctype.supertype_field = syms.objectType;
             ctype.interfaces_field = List.nil();
@@ -2269,7 +2274,8 @@
             case LEGACY:
                 return tree.packageAnnotations.nonEmpty();
             case NONEMPTY:
-                for (Attribute.Compound a: tree.packge.attributes_field) {
+                for (Attribute.Compound a :
+                         tree.packge.annotations.getAttributes()) {
                     Attribute.RetentionPolicy p = types.getRetention(a);
                     if (p != Attribute.RetentionPolicy.SOURCE)
                         return true;
@@ -3188,7 +3194,7 @@
          *
          * (where arrayexpr is of an array type) gets translated to
          *
-         * <pre>
+         * <pre>{@code
          *     for ( { arraytype #arr = arrayexpr;
          *             int #len = array.length;
          *             int #i = 0; };
@@ -3196,7 +3202,7 @@
          *         T v = arr$[#i];
          *         stmt;
          *     }
-         * </pre>
+         * }</pre>
          *
          * where #arr, #len, and #i are freshly named synthetic local variables.
          */
@@ -3266,14 +3272,14 @@
          *     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.
          */
@@ -3494,7 +3500,6 @@
                 JCExpression expression = oneCase.getExpression();
 
                 if (expression != null) { // expression for a "default" case is null
-                    expression = TreeInfo.skipParens(expression);
                     String labelExpr = (String) expression.type.constValue();
                     Integer mapping = caseLabelToPosition.put(labelExpr, casePosition);
                     Assert.checkNull(mapping);
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -76,11 +76,10 @@
     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 boolean skipAnnotations;
-
     public static MemberEnter instance(Context context) {
         MemberEnter instance = context.get(memberEnterKey);
         if (instance == null)
@@ -102,10 +101,9 @@
         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);
-        Options options = Options.instance(context);
-        skipAnnotations = options.isSet("skipAnnotations");
     }
 
     /** A queue for classes whose members still need to be entered into the
@@ -614,7 +612,7 @@
         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.getReturnType());
+            localEnv.info.returnResult = attr.new ResultInfo(VAL, tree.sym.type.getReturnType());
         }
         if ((tree.mods.flags & STATIC) != 0) localEnv.info.staticLevel++;
         return localEnv;
@@ -630,7 +628,11 @@
         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 {
+                attr.attribType(tree.vartype, localEnv);
+            }
         } finally {
             chk.setDeferredLintHandler(prevLintHandler);
         }
@@ -677,7 +679,7 @@
     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) {
-            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 ||
@@ -698,7 +700,7 @@
 
     public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) {
         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.annotations, tree.sym.flags());
         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)
@@ -735,18 +737,24 @@
     void annotateLater(final List<JCAnnotation> annotations,
                        final Env<AttrContext> localEnv,
                        final Symbol s) {
-        if (annotations.isEmpty()) return;
-        if (s.kind != PCK) s.attributes_field = null; // mark it incomplete for now
-        annotate.later(new Annotate.Annotator() {
+        if (annotations.isEmpty()) {
+            return;
+        }
+        if (s.kind != PCK) {
+            s.annotations.reset(); // 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() {
-                    Assert.check(s.kind == PCK || s.attributes_field == null);
+                    Assert.check(s.kind == PCK || s.annotations.pendingCompletion());
                     JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
                     try {
-                        if (s.attributes_field != null &&
-                            s.attributes_field.nonEmpty() &&
+                        if (!s.annotations.isEmpty() &&
                             annotations.nonEmpty())
                             log.error(annotations.head.pos,
                                       "already.annotated",
@@ -772,42 +780,62 @@
         return false;
     }
 
-
     /** Enter a set of annotations. */
     private void enterAnnotations(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;
-            if (!annotated.add(a.type.tsym))
-                log.error(a.pos, "duplicate.annotation");
+        }
         }
-        s.attributes_field = buf.toList();
+
+        s.annotations.setAttributesWithCompletion(
+                annotate.new AnnotateRepeatedContext(env, annotated, pos, log));
     }
 
     /** 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 {
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Oct 25 23:25:08 2012 +0100
@@ -27,10 +27,12 @@
 
 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.code.Symbol.*;
 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.InferenceContext.FreeTypeListener;
@@ -38,6 +40,7 @@
 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.JCMemberReference.ReferenceKind;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -47,11 +50,8 @@
 import java.util.Collection;
 import java.util.EnumMap;
 import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
+import java.util.Iterator;
 import java.util.Map;
-import java.util.Set;
 
 import javax.lang.model.element.ElementVisitor;
 
@@ -60,10 +60,7 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.Kinds.ERRONEOUS;
 import static com.sun.tools.javac.code.TypeTags.*;
-import com.sun.tools.javac.comp.DeferredAttr.AttrMode;
-import com.sun.tools.javac.comp.DeferredAttr.DeferredAttrContext;
 import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
-import com.sun.tools.javac.tree.JCTree.JCMemberReference.ReferenceKind;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
 /** Helper class for name resolution, used mostly by the attribution phase.
@@ -130,12 +127,11 @@
         polymorphicSignatureScope = new Scope(syms.noSymbol);
 
         inapplicableMethodException = new InapplicableMethodException(diags);
-        badVarargsMethodException = new BadVarargsMethodException(diags);
     }
 
     /** error symbols, which are returned when resolution fails
      */
-    private final SymbolNotFoundError varNotFound;    
+    private final SymbolNotFoundError varNotFound;
     private final SymbolNotFoundError methodNotFound;
     private final SymbolNotFoundError typeNotFound;
 
@@ -222,9 +218,11 @@
             }
         }
         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(Type.map(argtypes, deferredAttr.new RecoveryDeferredTypeMap(bestSoFar, currentResolutionContext.step))),
+                methodArguments(argtypes2),
                 methodArguments(typeargtypes));
         JCDiagnostic d = new JCDiagnostic.MultilineDiagnostic(main, subDiags.toList());
         log.report(d);
@@ -255,20 +253,9 @@
     /** An environment is "static" if its static level is greater than
      *  the one of its outer environment
      */
-    static boolean isStatic(Env<AttrContext> env) {
+    protected static boolean isStatic(Env<AttrContext> env) {
         return env.info.staticLevel > env.outer.info.staticLevel;
     }
-    
-    /**
-     * 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();
-    }
 
     /** An environment is an "initializer" if it is a constructor or
      *  an instance initializer.
@@ -518,8 +505,18 @@
                         boolean useVarargs,
                         Warner warn)
         throws Infer.InferenceException {
-        if (useVarargs && (m.flags() & VARARGS) == 0)
-            throw badVarargsMethodException.setMessage();
+        if (useVarargs && (m.flags() & VARARGS) == 0) {
+            //better error recovery - if we stumbled upon a non-varargs method
+            //during varargs applicability phase, the method should be treated as
+            //not applicable; the reason for inapplicability can be found in the
+            //candidate for 'm' that was created during the BOX phase.
+            Candidate prevCandidate = currentResolutionContext.getCandidate(m, BOX);
+            JCDiagnostic details = null;
+            if (prevCandidate != null && !prevCandidate.isApplicable()) {
+                details = prevCandidate.details;
+            }
+            throw inapplicableMethodException.setMessage(details);
+        }
         Type mt = types.memberType(site, m);
 
         // tvars is the list of formal type variables for which type arguments
@@ -565,8 +562,8 @@
             return infer.instantiateMethod(env,
                                     tvars,
                                     (MethodType)mt,
+                                    resultInfo,
                                     m,
-                                    resultInfo,
                                     argtypes,
                                     allowBoxing,
                                     useVarargs,
@@ -577,7 +574,7 @@
                                 allowBoxing, useVarargs, warn);
         return mt;
     }
-    
+
     Type checkMethod(Env<AttrContext> env,
                      Type site,
                      Symbol m,
@@ -691,7 +688,7 @@
      *
      * 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 'undte' form ahead of a compatibility
+     * 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
@@ -718,10 +715,10 @@
                 argtypes.size() != formals.size()) {
             throw handler.arityMismatch(); // not enough args
         }
-        
+
         DeferredAttr.DeferredAttrContext deferredAttrContext =
                 deferredAttr.new DeferredAttrContext(mode, msym, currentResolutionContext.step, inferenceContext);
-        
+
         while (argtypes.nonEmpty() && formals.head != varargsFormal) {
             ResultInfo mresult = methodCheckResult(formals.head, allowBoxing, false, inferenceContext, deferredAttrContext, handler, warn);
             mresult.check(null, argtypes.head);
@@ -745,10 +742,10 @@
             //check varargs element type accessibility
             varargsAccessible(env, elt, handler, inferenceContext);
         }
-        
+
         deferredAttrContext.complete();
     }
-    
+
     void varargsAccessible(final Env<AttrContext> env, final Type t, final Resolve.MethodCheckHandler handler, final InferenceContext inferenceContext) {
         if (inferenceContext.free(t)) {
             inferenceContext.addFreeTypeListener(List.of(t), new FreeTypeListener() {
@@ -787,7 +784,7 @@
         }
 
         public void report(DiagnosticPosition pos, JCDiagnostic details) {
-            throw handler.argumentMismatch(useVarargs, details);            
+            throw handler.argumentMismatch(useVarargs, details);
         }
 
         public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) {
@@ -817,6 +814,10 @@
         public boolean compatible(Type found, Type req, Warner warn) {
             return types.isSubtypeUnchecked(found, inferenceContext.asFree(req, types), warn);
         }
+
+        public boolean allowBoxing() {
+            return false;
+        }
     }
 
     /**
@@ -833,6 +834,10 @@
         public boolean compatible(Type found, Type req, Warner warn) {
             return types.isConvertible(found, inferenceContext.asFree(req, types), warn);
         }
+
+        public boolean allowBoxing() {
+            return true;
+        }
     }
 
     /**
@@ -846,29 +851,33 @@
                 new StrictMethodContext(methodHandler, useVarargs, inferenceContext, deferredAttrContext, rsWarner);
         return new MethodResultInfo(to, checkContext, deferredAttrContext);
     }
-    
+
     class MethodResultInfo extends ResultInfo {
-        
+
         DeferredAttr.DeferredAttrContext deferredAttrContext;
 
-        public MethodResultInfo(Type pt, MethodCheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) {
+        public MethodResultInfo(Type pt, CheckContext checkContext, DeferredAttr.DeferredAttrContext deferredAttrContext) {
             attr.super(VAL, pt, checkContext);
             this.deferredAttrContext = deferredAttrContext;
         }
-        
+
         @Override
         protected Type check(DiagnosticPosition pos, Type found) {
             if (found.tag == DEFERRED) {
-                DeferredType<?> dt = (DeferredType<?>)found;
+                DeferredType dt = (DeferredType)found;
                 return dt.check(this);
-            } else {
-                return super.check(pos, chk.checkNonVoid(pos, types.capture(types.upperBound(found.baseType()))));
             }
+            return super.check(pos, chk.checkNonVoid(pos, types.capture(types.upperBound(found.baseType()))));
         }
 
         @Override
         protected MethodResultInfo dup(Type newPt) {
-            return new MethodResultInfo(newPt, (MethodCheckContext)checkContext, deferredAttrContext);
+            return new MethodResultInfo(newPt, checkContext, deferredAttrContext);
+        }
+
+        @Override
+        protected ResultInfo dup(CheckContext newContext) {
+            return new MethodResultInfo(pt, newContext, deferredAttrContext);
         }
     }
 
@@ -886,7 +895,7 @@
             return setMessage((JCDiagnostic)null);
         }
         InapplicableMethodException setMessage(String key) {
-            return setMessage(this.diagnostic = key != null ? diags.fragment(key) : null);
+            return setMessage(key != null ? diags.fragment(key) : null);
         }
         InapplicableMethodException setMessage(String key, Object... args) {
             return setMessage(key != null ? diags.fragment(key, args) : null);
@@ -900,18 +909,7 @@
             return diagnostic;
         }
     }
-    
-    public static class BadVarargsMethodException extends InapplicableMethodException {
-        
-        private static final long serialVersionUID = 0;
-
-        public BadVarargsMethodException(JCDiagnostic.Factory diags) {
-            super(diags);
-        }
-    }
     private final InapplicableMethodException inapplicableMethodException;
-    private final BadVarargsMethodException badVarargsMethodException;
-    // </editor-fold>
 
 /* ***************************************************************************
  *  Symbol lookup
@@ -1072,30 +1070,9 @@
      *  @param allowBoxing Allow boxing conversions of arguments.
      *  @param useVarargs Box trailing arguments into an array for varargs.
      */
-    Symbol selectBest(Env<AttrContext> env,
-                      Type site,
-                      List<Type> argtypes,
-                      List<Type> typeargtypes,
-                      Symbol sym,
-                      Symbol bestSoFar,
-                      boolean allowBoxing,
-                      boolean useVarargs,
-                      boolean operator) {
-        return selectBest(env,
-                site,
-                null,
-                argtypes,
-                typeargtypes,
-                sym,
-                bestSoFar,
-                allowBoxing,
-                useVarargs,
-                operator);
-    }
     @SuppressWarnings("fallthrough")
     Symbol selectBest(Env<AttrContext> env,
                       Type site,
-                      ResultInfo resultInfo,
                       List<Type> argtypes,
                       List<Type> typeargtypes,
                       Symbol sym,
@@ -1107,12 +1084,10 @@
         if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
         Assert.check(sym.kind < AMBIGUOUS);
         try {
-            Type mt = rawInstantiate(env, site, sym, resultInfo, argtypes, typeargtypes,
+            Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
                                allowBoxing, useVarargs, Warner.noWarnings);
             if (!operator)
                 currentResolutionContext.addApplicableCandidate(sym, mt);
-        } catch (BadVarargsMethodException ex) {
-            return bestSoFar;
         } catch (InapplicableMethodException ex) {
             if (!operator)
                 currentResolutionContext.addInapplicableCandidate(sym, ex.getDiagnostic());
@@ -1217,8 +1192,8 @@
                             return this;
                         else
                             return super.implementation(origin, types, checkResult);
-                    }
-                };
+                        }
+                    };
                 return result;
             }
             if (m1SignatureMoreSpecific) return m1;
@@ -1246,20 +1221,20 @@
         Symbol m22 = adjustVarargs(m2, m1, useVarargs);
         Type mtype1 = types.memberType(site, m12);
         Type mtype2 = types.memberType(site, m22);
-        
+
         //check if invocation is more specific
         if (invocationMoreSpecific(env, site, m22, mtype1.getParameterTypes(), allowBoxing, useVarargs)) {
             return true;
         }
-        
+
         //perform structural check
-        
+
         List<Type> formals1 = mtype1.getParameterTypes();
         Type lastFormal1 = formals1.last();
         List<Type> formals2 = mtype2.getParameterTypes();
         Type lastFormal2 = formals2.last();
         ListBuffer<Type> newFormals = ListBuffer.lb();
-        
+
         boolean hasStructuralPoly = false;
         for (Type actual : actuals) {
             //perform formal argument adaptation in case actuals > formals (varargs)
@@ -1267,21 +1242,21 @@
                     lastFormal1 : formals1.head;
             Type f2 = formals2.isEmpty() ?
                     lastFormal2 : formals2.head;
-            
+
             //is this a structural actual argument?
             boolean isStructuralPoly = actual.tag == DEFERRED &&
-                    (((DeferredType<?>)actual).tree.hasTag(LAMBDA) ||
-                    ((DeferredType<?>)actual).tree.hasTag(REFERENCE));
-            
+                    (((DeferredType)actual).tree.hasTag(LAMBDA) ||
+                    ((DeferredType)actual).tree.hasTag(REFERENCE));
+
             Type newFormal = f1;
-            
+
             if (isStructuralPoly) {
                 //for structural arguments only - check that corresponding formals
                 //are related - if so replace formal with <null>
                 hasStructuralPoly = true;
-                DeferredType<?> dt = (DeferredType<?>)actual;                
-                Type t1 = deferredAttr.new SpeculativeDeferredTypeMap(m1, currentResolutionContext.step).apply(dt);
-                Type t2 = deferredAttr.new SpeculativeDeferredTypeMap(m2, currentResolutionContext.step).apply(dt);
+                DeferredType dt = (DeferredType)actual;
+                Type t1 = deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, m1, currentResolutionContext.step).apply(dt);
+                Type t2 = deferredAttr.new DeferredTypeMap(AttrMode.SPECULATIVE, m2, currentResolutionContext.step).apply(dt);
                 if (t1.isErroneous() || t2.isErroneous() || !isStructuralSubtype(t1, t2)) {
                     //not structural subtypes - simply fail
                     return false;
@@ -1289,7 +1264,7 @@
                     newFormal = syms.botType;
                 }
             }
-            
+
             newFormals.append(newFormal);
             if (newFormals.length() > mtype2.getParameterTypes().length()) {
                 //expand m2's type so as to fit the new formal arity (varargs)
@@ -1299,12 +1274,12 @@
             formals1 = formals1.isEmpty() ? formals1 : formals1.tail;
             formals2 = formals2.isEmpty() ? formals2 : formals2.tail;
         }
-        
+
         if (!hasStructuralPoly) {
             //if no structural actual was found, we're done
             return false;
         }
-        //perfomr additional adaptation if actuals < formals (varargs)
+        //perform additional adaptation if actuals < formals (varargs)
         for (Type t : formals1) {
             newFormals.append(t);
         }
@@ -1360,21 +1335,21 @@
 
         Type ret_s = types.findDescriptorType(s).getReturnType();
         Type ret_t = types.findDescriptorType(t).getReturnType();
-        
-        //covariant most specific check for functional descriptor return type
+
+        //covariant most specific check for function descriptor return type
         if (!types.isSubtype(ret_s, ret_t)) {
             return false;
         }
-        
+
         List<Type> args_s = types.findDescriptorType(s).getParameterTypes();
         List<Type> args_t = types.findDescriptorType(t).getParameterTypes();
-        
+
         //arity must be identical
         if (args_s.length() != args_t.length()) {
             return false;
         }
-        
-        //invariant most specific check for functional descriptor parameter types
+
+        //invariant most specific check for function descriptor parameter types
         if (!types.isSameTypes(args_t, args_s)) {
             return false;
         }
@@ -1431,93 +1406,163 @@
                       boolean allowBoxing,
                       boolean useVarargs,
                       boolean operator) {
-        return findMethod(env,
-                site,
-                name,
-                null,
-                argtypes,
-                typeargtypes,
-                allowBoxing,
-                useVarargs,
-                operator);
-    }
-    Symbol findMethod(Env<AttrContext> env,
-                      Type site,
-                      Name name,
-                      ResultInfo resultInfo,
-                      List<Type> argtypes,
-                      List<Type> typeargtypes,
-                      boolean allowBoxing,
-                      boolean useVarargs,
-                      boolean operator) {
         Symbol bestSoFar = methodNotFound;
         bestSoFar = findMethod(env,
                           site,
                           name,
-                          resultInfo,
                           argtypes,
                           typeargtypes,
                           site.tsym.type,
-                          true,
                           bestSoFar,
                           allowBoxing,
                           useVarargs,
-                          operator,
-                          new HashSet<TypeSymbol>());
+                          operator);
         reportVerboseResolutionDiagnostic(env.tree.pos(), name, site, argtypes, typeargtypes, bestSoFar);
         return bestSoFar;
     }
     // where
+    @SuppressWarnings("unchecked")
     private Symbol findMethod(Env<AttrContext> env,
                               Type site,
                               Name name,
-                              ResultInfo resultInfo,
                               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;
-            bestSoFar = lookupMethod(env, site, name, resultInfo, argtypes, typeargtypes,
-                    c.members(), bestSoFar, allowBoxing, useVarargs, operator, abstractok);
-            if (name == names.init)
-                break;
-            //- System.out.println(" - " + bestSoFar);
-            if (abstractok || allowDefenderMethods) {
-                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, resultInfo, argtypes,
-                                           typeargtypes,
-                                           l.head, abstractok, bestSoFar,
-                                           allowBoxing, useVarargs, operator, seen);
+                              boolean operator) {
+        EnumMap<InterfaceLookupPhase, List<Type>> itypesMap =
+                new EnumMap<InterfaceLookupPhase, List<Type>>(InterfaceLookupPhase.class);
+        for (InterfaceLookupPhase iphase : InterfaceLookupPhase.values()) {
+            itypesMap.put(iphase, List.<Type>nil());
+        }
+        InterfaceLookupPhase iphase = InterfaceLookupPhase.ABSTRACT_OK;
+        for (TypeSymbol s : superclasses(intype)) {
+            bestSoFar = lookupMethod(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)) {
+                    itypesMap.put(iphase, types.union(types.closure(itype), itypesMap.get(iphase)));
                 }
+            }            
+        }
+          Symbol concrete = bestSoFar.kind < ERR &&
+                (bestSoFar.flags() & ABSTRACT) == 0 ?
+                bestSoFar : methodNotFound;
+        
+        for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) {
+            if (iphase2 == InterfaceLookupPhase.DEFENDER_OK && !allowDefenderMethods) break;
+            //keep searching for abstract methods
+            for (Type itype : itypesMap.get(iphase2)) {
+                if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure())
+                if (iphase2 == InterfaceLookupPhase.DEFENDER_OK &&
+                        (itype.tsym.flags() & DEFENDER) == 0) continue;
+                bestSoFar = lookupMethod(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.allowDefenderMethods) {
+                    return DEFENDER_OK;
+                } else {
+                    return null;
+                }
+            }
+        },
+        DEFENDER_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.tag != CLASS &&
+                                t.tag != TYPEVAR) {
+                            return null;
+                        }
+                        while (t.tag == 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;
+                    }
+                };
+            }
+        };
+    }
+
+    /**
+     * Lookup a method with given name and argument types in a given scope
+     */
     Symbol lookupMethod(Env<AttrContext> env,
             Type site,
             Name name,
-            ResultInfo resultInfo,
             List<Type> argtypes,
             List<Type> typeargtypes,
             Scope sc,
@@ -1526,16 +1571,19 @@
             boolean useVarargs,
             boolean operator,
             boolean abstractok) {
-        for (Scope.Entry e = sc.lookup(name); e.scope != null; e = e.next()) {
-            if (e.sym.kind == MTH && (e.sym.flags_field & SYNTHETIC) == 0) {
-                if (!abstractok && (e.sym.flags() & ABSTRACT) != 0)
-                    continue;
-                bestSoFar = selectBest(env, site, resultInfo, argtypes, typeargtypes, e.sym,
-                        bestSoFar, allowBoxing, useVarargs, operator);
-            }
+        for (Symbol s : sc.getElementsByName(name, lookupFilter)) {
+            bestSoFar = selectBest(env, site, argtypes, typeargtypes, s,
+                    bestSoFar, allowBoxing, useVarargs, operator);
         }
         return bestSoFar;
     }
+    //where
+        Filter<Symbol> lookupFilter = new Filter<Symbol>() {
+            public boolean accepts(Symbol s) {
+                return s.kind == MTH &&
+                        (s.flags() & SYNTHETIC) == 0;
+            }
+        };
 
     /** Find unqualified method matching given name, type and value arguments.
      *  @param env       The current environment.
@@ -1827,7 +1875,7 @@
     /** 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.
@@ -1840,7 +1888,7 @@
      *                   if we looked for a method.
      *  @param typeargtypes  The invocation's type arguments,
      *                   if we looked for a method.
-     *  @param logResolveFilter filter used to decide as to whether a resolve diagnostic is to be generated
+     *  @param logResolveHelper helper class used to log resolve errors
      */
     Symbol accessInternal(Symbol sym,
                   DiagnosticPosition pos,
@@ -1851,7 +1899,7 @@
                   List<Type> argtypes,
                   List<Type> typeargtypes,
                   LogResolveHelper logResolveHelper) {
-        if (sym.kind >= AMBIGUOUS) {            
+        if (sym.kind >= AMBIGUOUS) {
             ResolveError errSym = (ResolveError)sym;
             sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol);
             argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes);
@@ -1861,7 +1909,7 @@
         }
         return sym;
     }
-    
+
     /**
      * Variant of the generalized access routine, to be used for generating method
      * resolution diagnostics
@@ -1911,12 +1959,12 @@
                   boolean 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();
@@ -1933,14 +1981,14 @@
                         (typeargtypes == null || !Type.isErroneous(typeargtypes));
         }
         public List<Type> getArgumentTypes(ResolveError errSym, Symbol accessedSym, Name name, List<Type> argtypes) {
-            if (isOperator(name)) {
+            if (syms.operatorNames.contains(name)) {
                 return argtypes;
             } else {
                 Symbol msym = errSym.kind == WRONG_MTH ?
                         ((InapplicableSymbolError)errSym).errCandidate().sym : accessedSym;
-                
+
                 List<Type> argtypes2 = Type.map(argtypes,
-                        deferredAttr.new RecoveryDeferredTypeMap(msym, currentResolutionContext.firstErroneousResolutionPhase()));
+                        deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, msym, currentResolutionContext.firstErroneousResolutionPhase()));
 
                 if (msym != accessedSym) {
                     //fixup deferred type caches - this 'hack' is required because the symbol
@@ -1949,7 +1997,7 @@
                     //causing problems in Attr.checkId()
                     for (Type t : argtypes) {
                         if (t.tag == DEFERRED) {
-                            DeferredType<?> dt = (DeferredType<?>)t;
+                            DeferredType dt = (DeferredType)t;
                             dt.speculativeCache.dupAllTo(msym, accessedSym);
                         }
                     }
@@ -2133,7 +2181,7 @@
                                             Symbol spMethod,
                                             List<Type> argtypes) {
         Type mtype = infer.instantiatePolymorphicSignatureInstance(env,
-                (MethodSymbol)spMethod, currentResolutionContext, argtypes);
+                (MethodSymbol)spMethod, currentResolutionContext, argtypes, this);
         for (Symbol sym : polymorphicSignatureScope.getElementsByName(spMethod.name)) {
             if (types.isSameType(mtype, sym.type)) {
                return sym;
@@ -2281,9 +2329,9 @@
 
     /** This method scans all the constructor symbol in a given class scope -
      *  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,
+     *  {@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:
-     *  <X,Y>Foo<X,Y>(X x, Y y). This is crucial in order to enable diamond
+     *  {@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.
      */
@@ -2322,33 +2370,28 @@
         }
         return bestSoFar;
     }
-    
+
     /**
      * Resolution of member references is typically done as a single
-     * overload resolution step, where the argument types A are either
-     * provided explicitly, or inferred fom the target SAM descriptor.
+     * overload resolution step, where the argument types A are inferred from
+     * the target functional descriptor.
      *
-     * There are however two cases in which resolution is done in a more
-     * convoluted two step-process:
-     *
-     * (a) - method reference with elided arguments with a type qualifier
-     * (b) - constructor reference with elided arguments involving a member inner class
+     * 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).
      *
-     * In the case of (a), two resolution steps are performed, one with the
-     * expected argument list A and one where the first element in A
-     * is discarded. The second step is only performed if the first element
-     * in the inferred argument list is a subtype of the qualifier expression type.
-     *
-     * In the case of (b), two resolution steps are performed, one with the
-     * expected argument list A and one where the first element in the inferred
-     * argument list is discarded. The first step is only performed if an
-     * implicit reference to an enclosing instance is available. The second
-     * step is only performed if the first element in the inferred argument
-     * list is a member of the enclosing 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
@@ -2367,12 +2410,12 @@
                 new MethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, boxingAllowed);
         Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup());
         Symbol boundSym = findMemberReference(boundEnv, boundLookupHelper);
-        
-        //step 2 - unbound lookup        
+
+        //step 2 - unbound lookup
         ReferenceLookupHelper unboundLookupHelper = boundLookupHelper.unboundLookup();
         Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup());
         Symbol unboundSym = findMemberReference(unboundEnv, unboundLookupHelper);
-        
+
         //merge results
         Pair<Symbol, ReferenceLookupHelper> res;
         if (unboundSym.kind != MTH) {
@@ -2385,14 +2428,25 @@
             res = new Pair<Symbol, ReferenceLookupHelper>(unboundSym, unboundLookupHelper);
             env.info.pendingResolutionPhase = unboundEnv.info.pendingResolutionPhase;
         }
-        
+
         return res;
     }
-    
+
+    /**
+     * 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;
         Type site;
+
+        /** actual types used during the lookup */
         List<Type> argtypes;
+
+        /** type arguments used during the lookup */
         List<Type> typeargtypes;
 
         LookupHelper(Name name, Type site, List<Type> argtypes, List<Type> typeargtypes) {
@@ -2401,15 +2455,31 @@
             this.argtypes = argtypes;
             this.typeargtypes = typeargtypes;
         }
-        
+
+        /**
+         * 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);
-        
+
+        /**
+         * Validate the result of the lookup
+         */
         abstract Symbol access(Env<AttrContext> env, Symbol symbol);
     }
-    
+
+    /**
+     * 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;
+
+        /** Max overload resolution phase handled by this helper */
         MethodResolutionPhase maxPhase;
 
         ReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site,
@@ -2418,7 +2488,11 @@
             this.referenceTree = referenceTree;
             this.maxPhase = boxingAllowed ? VARARITY : BASIC;
         }
-        
+
+        /**
+         * Returns an unbound version of this lookup helper. By default, this
+         * method returns an dummy lookup helper.
+         */
         ReferenceLookupHelper unboundLookup() {
             //dummy loopkup helper that always return 'methodNotFound'
             return new ReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase.isBoxingRequired()) {
@@ -2437,7 +2511,10 @@
                 }
             };
         }
-        
+
+        /**
+         * Get the kind of the member reference
+         */
         abstract JCMemberReference.ReferenceKind referenceKind(Symbol sym);
 
         @Override
@@ -2445,9 +2522,9 @@
             return (env.info.pendingResolutionPhase.ordinal() > maxPhase.ordinal()) ?
                     methodNotFound : lookupReference(env, phase);
         }
-        
+
         abstract Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase);
-        
+
         Symbol access(Env<AttrContext> env, Symbol sym) {
             if (sym.kind >= AMBIGUOUS) {
                 MethodResolutionPhase errPhase = currentResolutionContext.firstErroneousResolutionPhase();
@@ -2460,19 +2537,25 @@
             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, boolean boxingAllowed) {
             super(referenceTree, name, site, argtypes, typeargtypes, boxingAllowed);
         }
-        
+
         protected Symbol lookupReferenceInternal(Env<AttrContext> env, MethodResolutionPhase phase) {
             return findMethod(env, site, name, argtypes, typeargtypes,
-                    phase.isBoxingRequired(), phase.isVarargsRequired(), isOperator(name));
+                    phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name));
         }
-        
+
         protected Symbol adjustLookupResult(Env<AttrContext> env, Symbol sym) {
             return !TreeInfo.isStaticSelector(referenceTree.expr, names) ||
                         sym.kind != MTH ||
@@ -2481,7 +2564,7 @@
 
         @Override
         final Symbol lookupReference(Env<AttrContext> env, MethodResolutionPhase phase) {
-            return adjustLookupResult(env, lookupReferenceInternal(env, phase));            
+            return adjustLookupResult(env, lookupReferenceInternal(env, phase));
         }
 
         @Override
@@ -2489,9 +2572,8 @@
             if (TreeInfo.isStaticSelector(referenceTree.expr, names) &&
                     argtypes.nonEmpty() &&
                     types.isSubtypeUnchecked(argtypes.head, site)) {
-                Type unboundSite = site.isRaw() ? types.asSuper(argtypes.head, site.tsym) : site;
                 return new UnboundMethodReferenceLookupHelper(referenceTree, name,
-                        unboundSite, argtypes.tail, typeargtypes, maxPhase.isBoxingRequired());
+                        site, argtypes, typeargtypes, maxPhase.isBoxingRequired());
             } else {
                 return super.unboundLookup();
             }
@@ -2510,12 +2592,21 @@
             }
         }
     }
-    
+
+    /**
+     * 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, boolean boxingAllowed) {
-            super(referenceTree, name, site, argtypes, typeargtypes, boxingAllowed);
+            super(referenceTree, name,
+                    site.isRaw() ? types.asSuper(argtypes.head, site.tsym) : site,
+                    argtypes.tail, typeargtypes, boxingAllowed);
         }
 
         @Override
@@ -2533,9 +2624,17 @@
             return ReferenceKind.UNBOUND;
         }
     }
-    
-    class ConstructorReferenceLookupHelper extends MethodReferenceLookupHelper {
-        
+
+    /**
+     * 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,
@@ -2548,37 +2647,21 @@
         }
 
         @Override
-        ReferenceLookupHelper unboundLookup() {
-            if (argtypes.nonEmpty() &&
-                    site.getEnclosingType().tag != NONE &&
-                    types.asEnclosingSuper(argtypes.head, site.getEnclosingType().tsym) != null) {
-                return new UnboundConstructorReferenceLookupHelper(referenceTree, site, argtypes.tail,
-                        typeargtypes, maxPhase.isBoxingRequired());
-            } else {
-                return super.unboundLookup();
-            }
-        }
-        
-        @Override
-        protected Symbol lookupReferenceInternal(Env<AttrContext> env, MethodResolutionPhase phase) {
-            return needsInference ?
+        protected Symbol lookupReference(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(), isOperator(name));
-        }
-
-        @Override
-        protected Symbol adjustLookupResult(Env<AttrContext> env, Symbol sym) {
+                        phase.isBoxingRequired(), phase.isVarargsRequired(), syms.operatorNames.contains(name));
             return sym.kind != MTH ||
-                    site.getEnclosingType().tag == 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());
-                        }
-                    };
+                          site.getEnclosingType().tag == 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
@@ -2587,44 +2670,15 @@
                     ReferenceKind.TOPLEVEL : ReferenceKind.IMPLICIT_INNER;
         }
     }
-    
-    //TODO: this should be removed
-    class UnboundConstructorReferenceLookupHelper extends ConstructorReferenceLookupHelper {
-
-        UnboundConstructorReferenceLookupHelper(JCMemberReference referenceTree, Type site,
-                List<Type> argtypes, List<Type> typeargtypes, boolean boxingAllowed) {
-            super(referenceTree, site, argtypes, typeargtypes, boxingAllowed);
-        }
-
-        @Override
-        ReferenceLookupHelper unboundLookup() {
-            return this;
-        }
-
-        @Override
-        protected Symbol adjustLookupResult(Env<AttrContext> env, Symbol sym) {
-            return sym;
-        }
-
-        @Override
-        ReferenceKind referenceKind(Symbol sym) {
-            return ReferenceKind.UNBOUND_INNER;
-        }
-    }
 
     /**
-     * Resolution step for member reference. This is based upon a standard
-     * method/constructor resolution step, with two important differences:
-     * (i) if the resolved symbol is of the wrong kind (i.e. static symbol
-     * found where non-static symbol was expected) an erroneous symbol is
-     * returned; (ii) boxing/unboxing can be turned on/off on demand. This
-     * lookup 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).
+     * Resolution step for member reference. This generalizes a standard
+     * method/constructor lookup - on each overload resolution step, a
+     * lookup helper class is used to perform the reference lookup; at the end
+     * of the lookup, the helper is used to validate the results.
      */
     Symbol findMemberReference(Env<AttrContext> env, LookupHelper lookupHelper) {
-        MethodResolutionContext prevResolutionContext = currentResolutionContext;        
+        MethodResolutionContext prevResolutionContext = currentResolutionContext;
         try {
             currentResolutionContext = new MethodResolutionContext();
             Symbol sym = methodNotFound;
@@ -2827,12 +2881,12 @@
             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) {
@@ -2902,7 +2956,19 @@
     private final LocalizedString noArgs = new LocalizedString("compiler.misc.no.args");
 
     public Object methodArguments(List<Type> argtypes) {
-        return argtypes == null || argtypes.isEmpty() ? noArgs : argtypes;
+        if (argtypes == null || argtypes.isEmpty()) {
+            return noArgs;
+        } else {
+            ListBuffer<Object> diagArgs = ListBuffer.lb();
+            for (Type t : argtypes) {
+                if (t.tag == DEFERRED) {
+                    diagArgs.append(((DeferredAttr.DeferredType)t).tree);
+                } else {
+                    diagArgs.append(t);
+                }
+            }
+            return diagArgs;
+        }
     }
 
     /**
@@ -3027,7 +3093,7 @@
             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" :
@@ -3049,8 +3115,7 @@
                 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);
@@ -3100,8 +3165,8 @@
      * given an actual arguments/type argument list.
      */
     class InapplicableSymbolError extends ResolveError {
-        
-        MethodResolutionContext context;
+
+        protected MethodResolutionContext resolveContext;
 
         InapplicableSymbolError(MethodResolutionContext context) {
             this(WRONG_MTH, "inapplicable symbol error", context);
@@ -3109,7 +3174,7 @@
 
         protected InapplicableSymbolError(int kind, String debugName, MethodResolutionContext context) {
             super(kind, debugName);
-            this.context = context;
+            this.resolveContext = context;
         }
 
         @Override
@@ -3133,7 +3198,7 @@
             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" :
@@ -3147,7 +3212,7 @@
                 Candidate c = errCandidate();
                 Symbol ws = c.sym.asMemberOf(site, types);
                 return diags.create(dkind, log.currentSource(), pos,
-                          "cant.apply.symbol" + (c.details != null ? ".1" : ""),
+                          "cant.apply.symbol",
                           kindName(ws),
                           ws.name == names.init ? ws.owner.name : ws.name,
                           methodArguments(ws.type.getParameterTypes()),
@@ -3164,13 +3229,13 @@
         }
 
         protected boolean shouldReport(Candidate c) {
-            MethodResolutionPhase errPhase = context.firstErroneousResolutionPhase();
+            MethodResolutionPhase errPhase = resolveContext.firstErroneousResolutionPhase();
             return !c.isApplicable() &&
                     c.step == errPhase;
         }
 
         private Candidate errCandidate() {
-            for (Candidate c : context.candidates) {
+            for (Candidate c : resolveContext.candidates) {
                 if (shouldReport(c)) {
                     return c;
                 }
@@ -3199,14 +3264,14 @@
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes) {
-            if (context.candidates.nonEmpty()) {
+            if (!resolveContext.candidates.isEmpty()) {
                 JCDiagnostic err = diags.create(dkind,
                         log.currentSource(),
                         pos,
                         "cant.apply.symbols",
                         name == names.init ? KindName.CONSTRUCTOR : absentKind(kind),
                         getName(),
-                        argtypes);
+                        methodArguments(argtypes));
                 return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
             } else {
                 return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
@@ -3217,7 +3282,7 @@
         //where
         List<JCDiagnostic> candidateDetails(Type site) {
             List<JCDiagnostic> details = List.nil();
-            for (Candidate c : context.candidates) {
+            for (Candidate c : resolveContext.candidates) {
                 if (!shouldReport(c)) continue;
                 JCDiagnostic detailDiag = diags.fragment("inapplicable.method",
                         Kinds.kindName(c.sym),
@@ -3230,7 +3295,7 @@
         }
 
         private Name getName() {
-            Symbol sym = context.candidates.head.sym;
+            Symbol sym = resolveContext.candidates.head.sym;
             return sym.name == names.init ?
                 sym.owner.name :
                 sym.name;
@@ -3368,7 +3433,7 @@
         }
     }
 
-    public enum MethodResolutionPhase {
+    enum MethodResolutionPhase {
         BASIC(false, false),
         BOX(true, false),
         VARARITY(true, true);
@@ -3413,8 +3478,8 @@
 
         MethodResolutionPhase step = null;
 
-        boolean internalResolution = false;
-        DeferredAttr.AttrMode attrMode = DeferredAttr.AttrMode.SPECULATIVE;
+        private boolean internalResolution = false;
+        private DeferredAttr.AttrMode attrMode = DeferredAttr.AttrMode.SPECULATIVE;
 
         private MethodResolutionPhase firstErroneousResolutionPhase() {
             MethodResolutionPhase bestSoFar = BASIC;
@@ -3424,7 +3489,7 @@
                    steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
                    sym.kind >= WRONG_MTHS) {
                 sym = resolutionCache.get(steps.head);
-                if (sym.kind == ABSENT_MTH) break; //ignore spurious empty
+                if (sym.kind == ABSENT_MTH) break; //ignore spurious empty entries
                 bestSoFar = steps.head;
                 steps = steps.tail;
             }
@@ -3433,8 +3498,7 @@
 
         void addInapplicableCandidate(Symbol sym, JCDiagnostic details) {
             Candidate c = new Candidate(currentResolutionContext.step, sym, details, null);
-            if (!candidates.contains(c))
-                candidates = candidates.append(c);
+            candidates = candidates.append(c);
         }
 
         void addApplicableCandidate(Symbol sym, Type mtype) {
@@ -3442,6 +3506,16 @@
             candidates = candidates.append(c);
         }
 
+        Candidate getCandidate(Symbol sym, MethodResolutionPhase phase) {
+            for (Candidate c : currentResolutionContext.candidates) {
+                if (c.step == phase &&
+                        c.sym.baseSymbol() == sym.baseSymbol()) {
+                    return c;
+                }
+            }
+            return null;
+        }
+
         /**
          * This class represents an overload resolution candidate. There are two
          * kinds of candidates: applicable methods and inapplicable methods;
@@ -3469,9 +3543,9 @@
                     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))
+                            (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;
@@ -3481,11 +3555,11 @@
                 return mtype != null;
             }
         }
-        
+
         DeferredAttr.AttrMode attrMode() {
             return attrMode;
         }
-        
+
         boolean internal() {
             return internalResolution;
         }
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/src/share/classes/com/sun/tools/javac/file/Locations.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/Locations.java	Thu Oct 25 23:25:08 2012 +0100
@@ -733,11 +733,7 @@
                 urls[count++] = url;
             }
         }
-        if (urls.length != count) {
-            URL[] tmp = new URL[count];
-            System.arraycopy(urls, 0, tmp, 0, count);
-            urls = tmp;
-        }
+        urls = Arrays.copyOf(urls, count);
         return urls;
     }
 
--- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -36,6 +36,7 @@
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -284,7 +285,7 @@
         try {
             checkIndex();
             if (allDirs == Collections.EMPTY_SET) {
-                allDirs = new HashSet<RelativeDirectory>(directories.keySet());
+                allDirs = new java.util.LinkedHashSet<RelativeDirectory>(directories.keySet());
             }
 
             return allDirs;
@@ -572,7 +573,7 @@
 
             // Add each of the files
             if (entryCount > 0) {
-                directories = new HashMap<RelativeDirectory, DirectoryEntry>();
+                directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>();
                 ArrayList<Entry> entryList = new ArrayList<Entry>();
                 int pos = 2;
                 for (int i = 0; i < entryCount; i++) {
@@ -867,7 +868,7 @@
                 if (zipFile.lastModified() != fileStamp) {
                     ret = false;
                 } else {
-                    directories = new HashMap<RelativeDirectory, DirectoryEntry>();
+                    directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>();
                     int numDirs = raf.readInt();
                     for (int nDirs = 0; nDirs < numDirs; nDirs++) {
                         int dirNameBytesLen = raf.readInt();
--- a/src/share/classes/com/sun/tools/javac/jvm/ByteCodes.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ByteCodes.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 @@
 
     /** 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;
--- a/src/share/classes/com/sun/tools/javac/jvm/CRTable.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/CRTable.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,7 +31,7 @@
 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.parser.EndPosTable;
+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
@@ -162,7 +162,7 @@
     }
 
     /** 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);
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassFile.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -45,7 +45,7 @@
  *     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 +54,7 @@
  *     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.
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Oct 25 23:25:08 2012 +0100
@@ -191,7 +191,7 @@
 
     /** The current input pointer.
      */
-    int bp;
+    protected int bp;
 
     /** The objects of the constant pool.
      */
@@ -894,13 +894,13 @@
 
     protected enum AttributeKind { CLASS, MEMBER };
     protected abstract class AttributeReader {
-        AttributeReader(Name name, ClassFile.Version version, Set<AttributeKind> kinds) {
+        protected AttributeReader(Name name, ClassFile.Version version, Set<AttributeKind> kinds) {
             this.name = name;
             this.version = version;
             this.kinds = kinds;
         }
 
-        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;
@@ -919,11 +919,11 @@
             return false;
         }
 
-        abstract void read(Symbol sym, int attrLen);
+        protected abstract void read(Symbol sym, int attrLen);
 
-        final Name name;
-        final ClassFile.Version version;
-        final Set<AttributeKind> kinds;
+        protected final Name name;
+        protected final ClassFile.Version version;
+        protected final Set<AttributeKind> kinds;
     }
 
     protected Set<AttributeKind> CLASS_ATTRIBUTE =
@@ -940,7 +940,7 @@
             // v45.3 attributes
 
             new AttributeReader(names.Code, V45_3, MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (readAllOfClassFile || saveParameterNames)
                         ((MethodSymbol)sym).code = readCode(sym);
                     else
@@ -949,7 +949,7 @@
             },
 
             new AttributeReader(names.ConstantValue, V45_3, MEMBER_ATTRIBUTE) {
-                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)
@@ -958,13 +958,13 @@
             },
 
             new AttributeReader(names.Deprecated, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
-                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) {
-                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++)
@@ -975,14 +975,14 @@
             },
 
             new AttributeReader(names.InnerClasses, V45_3, CLASS_ATTRIBUTE) {
-                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) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     int newbp = bp + attrLen;
                     if (saveParameterNames) {
                         // Pick up parameter names from the variable table.
@@ -1018,7 +1018,7 @@
             },
 
             new AttributeReader(names.SourceFile, V45_3, CLASS_ATTRIBUTE) {
-                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);
@@ -1026,7 +1026,7 @@
             },
 
             new AttributeReader(names.Synthetic, V45_3, CLASS_OR_MEMBER_ATTRIBUTE) {
-                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;
@@ -1036,7 +1036,7 @@
             // standard v49 attributes
 
             new AttributeReader(names.EnclosingMethod, V49, CLASS_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     int newbp = bp + attrLen;
                     readEnclosingMethodAttr(sym);
                     bp = newbp;
@@ -1045,11 +1045,11 @@
 
             new AttributeReader(names.Signature, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
                 @Override
-                boolean accepts(AttributeKind kind) {
+                protected boolean accepts(AttributeKind kind) {
                     return super.accepts(kind) && allowGenerics;
                 }
 
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (sym.kind == TYP) {
                         ClassSymbol c = (ClassSymbol) sym;
                         readingClassAttr = true;
@@ -1078,31 +1078,31 @@
             // v49 annotation attributes
 
             new AttributeReader(names.AnnotationDefault, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachAnnotationDefault(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeInvisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachAnnotations(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeInvisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachParameterAnnotations(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeVisibleAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachAnnotations(sym);
                 }
             },
 
             new AttributeReader(names.RuntimeVisibleParameterAnnotations, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     attachParameterAnnotations(sym);
                 }
             },
@@ -1110,14 +1110,14 @@
             // additional "legacy" v49 attributes, superceded by flags
 
             new AttributeReader(names.Annotation, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (allowAnnotations)
                         sym.flags_field |= ANNOTATION;
                 }
             },
 
             new AttributeReader(names.Bridge, V49, MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     sym.flags_field |= BRIDGE;
                     if (!allowGenerics)
                         sym.flags_field &= ~SYNTHETIC;
@@ -1125,13 +1125,13 @@
             },
 
             new AttributeReader(names.Enum, V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                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) {
-                void read(Symbol sym, int attrLen) {
+                protected void read(Symbol sym, int attrLen) {
                     if (allowVarargs)
                         sym.flags_field |= VARARGS;
                 }
@@ -1157,7 +1157,7 @@
 
 
 
-    void readEnclosingMethodAttr(Symbol sym) {
+    protected void readEnclosingMethodAttr(Symbol sym) {
         // sym is a nested class with an "Enclosing Method" attribute
         // remove sym from it's current owners scope and place it in
         // the scope specified by the attribute
@@ -1325,7 +1325,7 @@
                 else
                     proxies.append(proxy);
             }
-            annotate.later(new AnnotationCompleter(sym, proxies.toList()));
+            annotate.normal(new AnnotationCompleter(sym, proxies.toList()));
         }
     }
 
@@ -1351,7 +1351,7 @@
     void attachAnnotationDefault(final Symbol sym) {
         final MethodSymbol meth = (MethodSymbol)sym; // only on methods
         final Attribute value = readAttributeValue();
-        annotate.later(new AnnotationDefaultCompleter(meth, value));
+        annotate.normal(new AnnotationDefaultCompleter(meth, value));
     }
 
     Type readTypeOrClassSymbol(int i) {
@@ -1697,10 +1697,13 @@
             JavaFileObject previousClassFile = currentClassFile;
             try {
                 currentClassFile = classFile;
+                Annotations annotations = sym.annotations;
                 List<Attribute.Compound> newList = deproxyCompoundList(l);
-                sym.attributes_field = ((sym.attributes_field == null)
-                                        ? newList
-                                        : newList.prependList(sym.attributes_field));
+                if (annotations.pendingCompletion()) {
+                    annotations.setAttributes(newList);
+                } else {
+                    annotations.append(newList);
+                }
             } finally {
                 currentClassFile = previousClassFile;
             }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -142,7 +142,7 @@
     /** The bootstrap methods to be written in the corresponding class attribute
      *  (one for each invokedynamic)
      */
-    Map<MethodSymbol, Pool.MemberReference> bootstrapMethods;
+    Map<MethodSymbol, Pool.MethodHandle> bootstrapMethods;
 
     /** The log to use for verbose output.
      */
@@ -171,7 +171,7 @@
 
     /** Construct a class writer, given an options table.
      */
-    private ClassWriter(Context context) {
+    protected ClassWriter(Context context) {
         context.put(classWriterKey, this);
 
         log = Log.instance(context);
@@ -493,7 +493,7 @@
                 } else {
                     //invokedynamic
                     DynamicMethodSymbol dynSym = (DynamicMethodSymbol)m;
-                    Pool.MemberReference handle = new Pool.MemberReference(dynSym.bsmKind, dynSym.bsm);
+                    Pool.MethodHandle handle = new Pool.MethodHandle(dynSym.bsmKind, dynSym.bsm);
                     bootstrapMethods.put(dynSym, handle);
                     //init cp entries
                     pool.put(names.BootstrapMethods);
@@ -558,8 +558,8 @@
                 if (type.tag == CLASS) enterInner((ClassSymbol)type.tsym);
                 poolbuf.appendByte(CONSTANT_Class);
                 poolbuf.appendChar(pool.put(xClassName(type)));
-            } else if (value instanceof Pool.MemberReference) {
-                Pool.MemberReference ref = (Pool.MemberReference)value;
+            } else if (value instanceof Pool.MethodHandle) {
+                Pool.MethodHandle ref = (Pool.MethodHandle)value;
                 poolbuf.appendByte(CONSTANT_MethodHandle);
                 poolbuf.appendByte(ref.refKind);
                 poolbuf.appendChar(pool.put(ref.refSym));
@@ -633,12 +633,20 @@
      *  Returns the number of attributes written (0 or 1).
      */
     int writeEnclosingMethodAttribute(ClassSymbol c) {
-        if (!target.hasEnclosingMethodAttribute() ||
-            c.owner.kind != MTH && // neither a local class
+        if (!target.hasEnclosingMethodAttribute())
+            return 0;
+        return writeEnclosingMethodAttribute(names.EnclosingMethod, c);
+    }
+
+    /** Write the EnclosingMethod attribute with a specified name.
+     *  Returns the number of attributes written (0 or 1).
+     */
+    protected int writeEnclosingMethodAttribute(Name attributeName, ClassSymbol c) {
+        if (c.owner.kind != MTH && // neither a local class
             c.name != names.empty) // nor anonymous
             return 0;
 
-        int alenIdx = writeAttr(names.EnclosingMethod);
+        int alenIdx = writeAttr(attributeName);
         ClassSymbol enclClass = c.owner.enclClass();
         MethodSymbol enclMethod =
             (c.owner.type == null // local to init block
@@ -849,7 +857,7 @@
         }
         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('@');
@@ -943,7 +951,7 @@
     void writeBootstrapMethods() {
         int alenIdx = writeAttr(names.BootstrapMethods);
         databuf.appendChar(bootstrapMethods.size());
-        for (Map.Entry<MethodSymbol, Pool.MemberReference> entry : bootstrapMethods.entrySet()) {
+        for (Map.Entry<MethodSymbol, Pool.MethodHandle> entry : bootstrapMethods.entrySet()) {
             DynamicMethodSymbol dsym = (DynamicMethodSymbol)entry.getKey();
             //write BSM handle
             databuf.appendChar(pool.get(entry.getValue()));
@@ -1526,7 +1534,7 @@
         pool = c.pool;
         innerClasses = null;
         innerClassesQueue = null;
-        bootstrapMethods = new LinkedHashMap<MethodSymbol, Pool.MemberReference>();
+        bootstrapMethods = new LinkedHashMap<MethodSymbol, Pool.MethodHandle>();
 
         Type supertype = types.supertype(c.type);
         List<Type> interfaces = types.interfaces(c.type);
@@ -1621,6 +1629,7 @@
         acount += writeFlagAttrs(c.flags());
         acount += writeJavaAnnotations(c.getAnnotationMirrors());
         acount += writeEnclosingMethodAttribute(c);
+        acount += writeExtraClassAttributes(c);
 
         poolbuf.appendInt(JAVA_MAGIC);
         poolbuf.appendChar(target.minorVersion);
@@ -1646,6 +1655,14 @@
         pool = c.pool = null; // to conserve space
      }
 
+    /**Allows subclasses to write additional class attributes
+     *
+     * @return the number of attributes written
+     */
+    protected int writeExtraClassAttributes(ClassSymbol c) {
+        return 0;
+    }
+
     int adjustFlags(final long flags) {
         int result = (int)flags;
         if ((flags & SYNTHETIC) != 0  && !target.useSyntheticFlag())
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -122,7 +122,7 @@
 
 /*---------- internal fields: --------------- */
 
-    /** Are we generating code with jumps >= 32K?
+    /** Are we generating code with jumps &ge; 32K?
      */
     public boolean fatcode;
 
@@ -314,11 +314,7 @@
      */
     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;
     }
 
@@ -903,7 +899,8 @@
         if (o instanceof Double) return syms.doubleType;
         if (o instanceof ClassSymbol) return syms.classType;
         if (o instanceof Type.ArrayType) return syms.classType;
-        if (o instanceof Pool.MemberReference) return syms.methodHandleType;
+        if (o instanceof Type.MethodType) return syms.methodTypeType;
+        if (o instanceof Pool.MethodHandle) return syms.methodHandleType;
         throw new AssertionError(o);
     }
 
@@ -1078,13 +1075,15 @@
             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
@@ -1092,7 +1091,8 @@
         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
@@ -1243,12 +1243,8 @@
 
         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();
@@ -1316,12 +1312,10 @@
 
         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);
@@ -1647,10 +1641,8 @@
         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++;
@@ -1676,11 +1668,7 @@
             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:
@@ -1867,13 +1855,7 @@
     /** 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);
@@ -1953,11 +1935,8 @@
         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;
     }
 
@@ -1991,7 +1970,7 @@
         nextreg = max_locals;
     }
 
-    /** End scopes of all variables with registers >= first.
+    /** End scopes of all variables with registers &ge; first.
      */
     public void endScopes(int first) {
         int prevNextReg = nextreg;
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -37,8 +37,7 @@
 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.parser.EndPosTable;
-import com.sun.tools.javac.jvm.Pool.*;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree.*;
 
 import static com.sun.tools.javac.code.Flags.*;
@@ -124,6 +123,7 @@
             : options.isSet(G_CUSTOM, "vars");
         genCrt = options.isSet(XJCOV);
         debugCode = options.isSet("debugcode");
+        allowInvokedynamic = target.hasInvokedynamic();
 
         generateIproxies =
             target.requiresIproxy() ||
@@ -160,6 +160,7 @@
     private final boolean varDebugInfo;
     private final boolean genCrt;
     private final boolean debugCode;
+    private final boolean allowInvokedynamic;
 
     /** Default limit of (approximate) size of finalizer to inline.
      *  Zero means always use jsr.  100 or greater means never use
@@ -246,10 +247,10 @@
     /** 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
@@ -2147,7 +2148,9 @@
             // We are seeing a variable that is constant but its selecting
             // expression is not.
             if ((sym.flags() & STATIC) != 0) {
-                base.exec();
+                if (!selectSuper && (ssym == null || ssym.kind != TYP))
+                    base = base.load();
+                base.drop();
             } else {
                 base.load();
                 genNullCheck(tree.selected.pos());
@@ -2161,9 +2164,10 @@
             } else if (!accessSuper) {
                 sym = binaryQualifier(sym, tree.selected.type);
             }
-
             if ((sym.flags() & STATIC) != 0) {
-                base.exec();
+                if (!selectSuper && (ssym == null || ssym.kind != TYP))
+                    base = base.load();
+                base.drop();
                 result = items.makeStaticItem(sym);
             } else {
                 base.load();
@@ -2184,11 +2188,6 @@
         return sym.kind == MTH && ((MethodSymbol)sym).isDynamic();
     }
 
-    public void visitReference(JCMemberReference tree) {
-        //should have been desugared in LambdaTranslator
-        throw new AssertionError();
-    }
-
     public void visitLiteral(JCLiteral tree) {
         if (tree.type.tag == TypeTags.BOT) {
             code.emitop0(aconst_null);
--- a/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/JNIWriter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -157,7 +157,7 @@
         if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
             return false;
 
-        for (Attribute.Compound a: c.attributes_field) {
+        for (Attribute.Compound a: c.annotations.getAttributes()) {
             if (a.type.tsym == syms.nativeHeaderType.tsym)
                 return true;
         }
--- a/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,14 +25,16 @@
 
 package com.sun.tools.javac.jvm;
 
-import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Kinds;
-import java.util.*;
-
 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.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.
  *
@@ -88,44 +90,38 @@
         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 Symbol && !(value instanceof ClassSymbol) && !(value instanceof DynamicMethodSymbol))
-            value = delegateSymbol((Symbol) 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();
     }
-
-    static DelegatedSymbol delegateSymbol(Symbol value) {
-        if (value instanceof MethodSymbol)
-            return new Method((MethodSymbol)value);
-        else if (value instanceof VarSymbol)
-            return new Variable((VarSymbol)value);
-        else
-            return (DelegatedSymbol) value;
+    
+    Object makePoolValue(Object o) {
+        if (o instanceof DynamicMethodSymbol) {
+            return new DynamicMethod((DynamicMethodSymbol)o);
+        } else if (o instanceof MethodSymbol) {
+            return new Method((MethodSymbol)o);
+        } else if (o instanceof VarSymbol) {
+            return new Variable((VarSymbol)o);
+        } else {
+            return o;
+        }
     }
 
     /** Return the given object's index in the pool,
@@ -157,6 +153,36 @@
                 m.type.hashCode();
         }
     }
+    
+    static class DynamicMethod extends Method {
+
+        DynamicMethod(DynamicMethodSymbol m) {
+            super(m);
+        }
+
+        @Override
+        public boolean equals(Object other) {
+            if (!super.equals(other)) return false;
+            if (!(other instanceof DynamicMethod)) return false;
+            DynamicMethodSymbol dm1 = (DynamicMethodSymbol)m;
+            DynamicMethodSymbol dm2 = (DynamicMethodSymbol)((DynamicMethod)other).m;
+            return dm1.bsm == dm2.bsm &&
+                        dm1.bsmKind == dm2.bsmKind &&
+                        Arrays.equals(dm1.staticArgs, dm2.staticArgs);
+        }
+
+        @Override
+        public int hashCode() {
+            int hash = super.hashCode();
+            DynamicMethodSymbol dm = (DynamicMethodSymbol)m;
+            hash += dm.bsmKind * 7 +
+                    dm.bsm.hashCode() * 11;
+            for (int i = 0; i < dm.staticArgs.length; i++) {
+                hash += (dm.staticArgs[i].hashCode() * 23) >> i;
+            }
+            return hash;
+        }
+    }
 
     static class Variable extends DelegatedSymbol {
         VarSymbol v;
@@ -179,18 +205,23 @@
                 v.type.hashCode();
         }
     }
-    
-    public static class MemberReference {
-        int refKind;  // e.g., ClassFile.REF_invokeStatic, etc.
+
+    public static class MethodHandle {
+
+        /** Reference kind - see ClassFile */
+        int refKind;
+
+        /** Reference symbol */
         Symbol refSym;
-        public MemberReference(int refKind, Symbol refSym) {
+
+        public MethodHandle(int refKind, Symbol refSym) {
             this.refKind = refKind;
             this.refSym = refSym;
-            Assert.check(isConsistent());
+            checkConsistent();
         }
         public boolean equals(Object other) {
-            if (!(other instanceof MemberReference)) return false;
-            MemberReference mr = (MemberReference) other;
+            if (!(other instanceof MethodHandle)) return false;
+            MethodHandle mr = (MethodHandle) other;
             if (mr.refKind != refKind)  return false;
             Symbol o = mr.refSym;
             return
@@ -206,40 +237,54 @@
                 refSym.type.hashCode();
         }
 
-        public static int methodRefKind(boolean isStatic, boolean isInterface) {
-            if (isStatic)
-                return ClassFile.REF_invokeStatic;
-            else if (isInterface)
-                return ClassFile.REF_invokeInterface;
-            else
-                return ClassFile.REF_invokeVirtual;
-        }
-
-        public static int specialRefKind(boolean isConstructor) {
-            if (!isConstructor)
-                return ClassFile.REF_invokeSpecial;
-            else
-                return ClassFile.REF_newInvokeSpecial;
-        }
-
-        private boolean isConsistent() {
-            // Check consistency of reference kind and symbol.
-            // Methods invoked, fields get/put; static must match, etc.
-            boolean isStatic = refSym.isStatic();
-            int expectedRefKind;
-            switch (refSym.kind) {
-                case Kinds.MTH:
-                    if (refSym.isConstructor())
-                        return (refKind == specialRefKind(true));
-                    expectedRefKind = methodRefKind(isStatic, refSym.owner.isInterface());
-                    if (refKind == expectedRefKind)
-                        return true;
-                    if (expectedRefKind == ClassFile.REF_invokeVirtual
-                             && refKind == ClassFile.REF_invokeSpecial)
-                        return true;  // assume access is OK
+        /**
+         * 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:
+                    staticOk = true;
+                case ClassFile.REF_invokeVirtual:
+                case ClassFile.REF_invokeSpecial:
+                    expectedKind = Kinds.MTH;
                     break;
             }
-            return false;
+            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;
+                    }
+                };
     }
 }
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Oct 25 23:25:08 2012 +0100
@@ -415,10 +415,17 @@
             ? 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));
     }
@@ -495,12 +502,20 @@
     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 shouldStopPolicy;
+    public CompileState shouldStopPolicyIfError;
 
-    /** A queue of all as yet unattributed classes.
+    /**
+     * 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 shouldStopPolicyIfNoError;
+
+    /** A queue of all as yet unattributed classes.oLo
      */
     public Todo todo;
 
@@ -510,6 +525,7 @@
 
     /** Ordered list of compiler phases for each compilation unit. */
     public enum CompileState {
+        INIT(0),
         PARSE(1),
         ENTER(2),
         PROCESS(3),
@@ -523,8 +539,11 @@
         CompileState(int value) {
             this.value = value;
         }
-        boolean isDone(CompileState other) {
-            return value >= other.value;
+        boolean isAfter(CompileState other) {
+            return value > other.value;
+        }
+        public static CompileState max(CompileState a, CompileState b) {
+            return a.value > b.value ? a : b;
         }
         private int value;
     };
@@ -535,7 +554,7 @@
         private static final long serialVersionUID = 1812267524140424433L;
         boolean isDone(Env<AttrContext> env, CompileState cs) {
             CompileState ecs = get(env);
-            return ecs != null && ecs.isDone(cs);
+            return (ecs != null) && !cs.isAfter(ecs);
         }
     }
     private CompileStates compileStates = new CompileStates();
@@ -547,10 +566,10 @@
     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.
@@ -935,6 +954,18 @@
     }
 
     /**
+     * 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.
@@ -1660,6 +1691,8 @@
         hasBeenUsed = true;
         closeables = prev.closeables;
         prev.closeables = List.nil();
+        shouldStopPolicyIfError = prev.shouldStopPolicyIfError;
+        shouldStopPolicyIfNoError = prev.shouldStopPolicyIfNoError;
     }
 
     public static void enableLogging() {
--- a/src/share/classes/com/sun/tools/javac/main/Main.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -177,7 +177,7 @@
         }
 
         public void visitClass(Attribute.Class c) {
-            value = new MirroredTypeExceptionProxy(c.type);
+            value = new MirroredTypeExceptionProxy(c.classType);
         }
 
         public void visitArray(Attribute.Array a) {
@@ -187,7 +187,7 @@
                 // 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());
--- a/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -28,11 +28,14 @@
 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;
@@ -47,9 +50,7 @@
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.Name;
-
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
-import static javax.lang.model.util.ElementFilter.methodsIn;
 
 /**
  * Utility methods for operating on program elements.
@@ -361,7 +362,7 @@
         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) {
--- a/src/share/classes/com/sun/tools/javac/parser/EndPosTable.java	Fri Oct 19 17:48:08 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 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.tree.JCTree;
-
-/**
- * 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);
-}
--- a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -571,7 +571,7 @@
                             reader.scanCommentChar();
                         } while (reader.ch != CR && reader.ch != LF && reader.bp < reader.buflen);
                         if (reader.bp < reader.buflen) {
-                            comments = addDocReader(comments, processComment(pos, reader.bp, CommentStyle.LINE));
+                            comments = addComment(comments, processComment(pos, reader.bp, CommentStyle.LINE));
                         }
                         break;
                     } else if (reader.ch == '*') {
@@ -597,7 +597,7 @@
                         }
                         if (reader.ch == '/') {
                             reader.scanChar();
-                            comments = addDocReader(comments, processComment(pos, reader.bp, style));
+                            comments = addComment(comments, processComment(pos, reader.bp, style));
                             break;
                         } else {
                             lexError(pos, "unclosed.comment");
@@ -638,10 +638,6 @@
                         lexError(pos, "unclosed.str.lit");
                     }
                     break loop;
-                case '#':
-                    reader.scanChar();
-                    tk = TokenKind.HASH;
-                    break loop;
                 default:
                     if (isSpecial(reader.ch)) {
                         scanOperator();
@@ -693,10 +689,10 @@
         }
     }
     //where
-        List<Comment> addDocReader(List<Comment> docReaders, Comment docReader) {
-            return docReaders == null ?
-                    List.of(docReader) :
-                    docReaders.prepend(docReader);
+        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;
@@ -780,6 +776,10 @@
             return null;
         }
 
+        public int getSourcePos(int pos) {
+            return -1;
+        }
+
         public CommentStyle getStyle() {
             return cs;
         }
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -39,7 +39,6 @@
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
 
-import static com.sun.tools.javac.util.ListBuffer.lb;
 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;
@@ -117,7 +116,7 @@
         this.allowLambda = source.allowLambda();
         this.allowMethodReferences = source.allowMethodReferences();
         this.keepDocComments = keepDocComments;
-        docComments = keepDocComments ? new HashMap<JCTree,String>() : null;
+        docComments = newDocCommentTable(keepDocComments);
         this.keepLineMap = keepLineMap;
         this.errorTree = F.Erroneous();
         endPosTable = newEndPosTable(keepEndPositions);
@@ -128,6 +127,11 @@
                 ? new SimpleEndPosTable()
                 : new EmptyEndPosTable();
     }
+
+    protected DocCommentTable newDocCommentTable(boolean keepDocComments) {
+        return keepDocComments ? new SimpleDocCommentTable() : null;
+    }
+
     /** Switch: Should generics be recognized?
      */
     boolean allowGenerics;
@@ -421,21 +425,21 @@
 
 /* ---------- 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);
         }
     }
 
@@ -669,6 +673,7 @@
     }
 
     /**
+     *  {@literal
      *  Expression = Expression1 [ExpressionRest]
      *  ExpressionRest = [AssignmentOperator Expression1]
      *  AssignmentOperator = "=" | "+=" | "-=" | "*=" | "/=" |
@@ -678,6 +683,7 @@
      *  TypeNoParams = TypeNoParams1
      *  StatementExpression = Expression
      *  ConstantExpression = Expression
+     *  }
      */
     JCExpression term() {
         JCExpression t = term1();
@@ -883,9 +889,12 @@
             return opStack;
         }
 
-    /** Expression3    = PrefixOp Expression3
+    /**
+     *  Expression3    = PrefixOp Expression3
      *                 | "(" Expr | TypeNoParams ")" Expression3
      *                 | Primary {Selector} {PostfixOp}
+     *
+     *  {@literal
      *  Primary        = "(" Expression ")"
      *                 | Literal
      *                 | [TypeArguments] THIS [Arguments]
@@ -900,6 +909,8 @@
      *                   | "." ( CLASS | THIS | [TypeArguments] SUPER Arguments | NEW [TypeArguments] InnerCreator )
      *                   ]
      *                 | BasicType BracketsOpt "." CLASS
+     *  }
+     *
      *  PrefixOp       = "++" | "--" | "!" | "~" | "+" | "-"
      *  PostfixOp      = "++" | "--"
      *  Type3          = Ident { "." Ident } [TypeArguments] {TypeSelector} BracketsOpt
@@ -1309,10 +1320,11 @@
                 case GT:
                     depth--;
                     if (depth == 0) {
+                        TokenKind nextKind = S.token(pos + 1).kind;
                         return
-                            S.token(pos + 1).kind == TokenKind.DOT ||
-                            S.token(pos + 1).kind == TokenKind.LBRACKET ||
-                            S.token(pos + 1).kind == TokenKind.COLCOL;
+                            nextKind == TokenKind.DOT ||
+                            nextKind == TokenKind.LBRACKET ||
+                            nextKind == TokenKind.COLCOL;
                     }
                     break;
                 default:
@@ -1454,7 +1466,10 @@
         return null;
     }
 
-    /**  TypeArguments  = "<" TypeArgument {"," TypeArgument} ">"
+    /**
+     *  {@literal
+     *  TypeArguments  = "<" TypeArgument {"," TypeArgument} ">"
+     *  }
      */
     List<JCExpression> typeArguments(boolean diamondAllowed) {
         if (token.kind == LT) {
@@ -1491,10 +1506,13 @@
         }
     }
 
-    /** TypeArgument = Type
+    /**
+     *  {@literal
+     *  TypeArgument = Type
      *               | "?"
      *               | "?" EXTENDS Type {"&" Type}
      *               | "?" SUPER Type
+     *  }
      */
     JCExpression typeArgument() {
         if (token.kind != QUES) return parseType();
@@ -1581,8 +1599,8 @@
     }
 
     /**
-     * MemberReferenceSuffix = "#" [TypeArguments] Ident
-     *                       | "#" [TypeArguments] "new"
+     * MemberReferenceSuffix = "::" [TypeArguments] Ident
+     *                       | "::" [TypeArguments] "new"
      */
     JCExpression memberReferenceSuffix(JCExpression t) {
         int pos1 = token.pos;
@@ -1806,92 +1824,126 @@
      */
     @SuppressWarnings("fallthrough")
     List<JCStatement> blockStatements() {
-//todo: skip to anchor on error(?)
-        int lastErrPos = -1;
+        //todo: skip to anchor on error(?)
         ListBuffer<JCStatement> stats = new ListBuffer<JCStatement>();
         while (true) {
-            int pos = token.pos;
-            switch (token.kind) {
-            case RBRACE: case CASE: case DEFAULT: case EOF:
+            List<JCStatement> stat = blockStatement();
+            if (stat.isEmpty()) {
                 return stats.toList();
-            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:
-                stats.append(parseStatement());
+            } else {
+                if (token.pos <= endPosTable.errorEndPos) {
+                    skip(false, true, true, true);
+                }
+                stats.addAll(stat);
+            }
+        }
+    }
+
+    /*
+     * 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 = F.at(pos).Erroneous();
+            error(e, "illegal.start.of.stmt");
+            return F.at(pos).Exec(e);
+        } else {
+            JCStatement first = stats.head;
+            String error = null;
+            switch (first.getTag()) {
+            case CLASSDEF:
+                error = "class.not.allowed";
                 break;
-            case MONKEYS_AT:
-            case FINAL: {
-                String dc = token.comment(CommentStyle.JAVADOC);
-                JCModifiers mods = modifiersOpt();
-                if (token.kind == INTERFACE ||
-                    token.kind == CLASS ||
-                    allowEnums && token.kind == 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.elems.last(), token.endPos);
-                    accept(SEMI);
-                }
-                break;
-            }
-            case ABSTRACT: case STRICTFP: {
-                String dc = token.comment(CommentStyle.JAVADOC);
-                JCModifiers mods = modifiersOpt();
-                stats.append(classOrInterfaceOrEnumDeclaration(mods, dc));
+            case VARDEF:
+                error = "variable.not.allowed";
                 break;
             }
-            case INTERFACE:
-            case CLASS:
-                String dc = token.comment(CommentStyle.JAVADOC);
-                stats.append(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
-                break;
-            case ENUM:
-            case ASSERT:
-                if (allowEnums && token.kind == ENUM) {
-                    error(token.pos, "local.enum");
-                    dc = token.comment(CommentStyle.JAVADOC);
-                    stats.append(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
-                    break;
-                } else if (allowAsserts && token.kind == ASSERT) {
-                    stats.append(parseStatement());
-                    break;
-                }
-                /* fall through to default */
-            default:
-                Token prevToken = token;
-                JCExpression t = term(EXPR | TYPE);
-                if (token.kind == COLON && t.hasTag(IDENT)) {
-                    nextToken();
-                    JCStatement stat = parseStatement();
-                    stats.append(F.at(pos).Labelled(prevToken.name(), stat));
-                } else if ((lastmode & TYPE) != 0 &&
-                           (token.kind == IDENTIFIER ||
-                            token.kind == ASSERT ||
-                            token.kind == ENUM)) {
-                    pos = token.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
-                    storeEnd(stats.elems.last(), token.endPos);
-                    accept(SEMI);
-                } else {
-                    // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon
-                    stats.append(to(F.at(pos).Exec(checkExprStat(t))));
-                    accept(SEMI);
-                }
+            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() {
+        //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.elems.last(), token.endPos);
+                accept(SEMI);
+                return stats.toList();
             }
-
-            // error recovery
-            if (token.pos == lastErrPos)
+        }
+        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 &&
+                       (token.kind == IDENTIFIER ||
+                        token.kind == ASSERT ||
+                        token.kind == ENUM)) {
+                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
+                storeEnd(stats.elems.last(), token.endPos);
+                accept(SEMI);
                 return stats.toList();
-            if (token.pos <= endPosTable.errorEndPos) {
-                skip(false, true, true, true);
-                lastErrPos = token.pos;
+            } else {
+                // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon
+                JCExpressionStatement expr = to(F.at(pos).Exec(checkExprStat(t)));
+                accept(SEMI);
+                return List.<JCStatement>of(expr);
             }
         }
     }
@@ -1925,11 +1977,11 @@
         case IF: {
             nextToken();
             JCExpression cond = parExpression();
-            JCStatement thenpart = parseStatement();
+            JCStatement thenpart = parseStatementAsBlock();
             JCStatement elsepart = null;
             if (token.kind == ELSE) {
                 nextToken();
-                elsepart = parseStatement();
+                elsepart = parseStatementAsBlock();
             }
             return F.at(pos).If(cond, thenpart, elsepart);
         }
@@ -1946,7 +1998,7 @@
                 accept(COLON);
                 JCExpression expr = parseExpression();
                 accept(RPAREN);
-                JCStatement body = parseStatement();
+                JCStatement body = parseStatementAsBlock();
                 return F.at(pos).ForeachLoop(var, expr, body);
             } else {
                 accept(SEMI);
@@ -1954,19 +2006,19 @@
                 accept(SEMI);
                 List<JCExpressionStatement> steps = token.kind == RPAREN ? List.<JCExpressionStatement>nil() : forUpdate();
                 accept(RPAREN);
-                JCStatement body = parseStatement();
+                JCStatement body = parseStatementAsBlock();
                 return F.at(pos).ForLoop(inits, cond, steps, body);
             }
         }
         case WHILE: {
             nextToken();
             JCExpression cond = parExpression();
-            JCStatement body = parseStatement();
+            JCStatement body = parseStatementAsBlock();
             return F.at(pos).WhileLoop(cond, body);
         }
         case DO: {
             nextToken();
-            JCStatement body = parseStatement();
+            JCStatement body = parseStatementAsBlock();
             accept(WHILE);
             JCExpression cond = parExpression();
             JCDoWhileLoop t = to(F.at(pos).DoLoop(body, cond));
@@ -2121,27 +2173,10 @@
         while (true) {
             int pos = token.pos;
             switch (token.kind) {
-            case CASE: {
-                nextToken();
-                JCExpression pat = parseExpression();
-                accept(COLON);
-                List<JCStatement> stats = blockStatements();
-                JCCase c = F.at(pos).Case(pat, stats);
-                if (stats.isEmpty())
-                    storeEnd(c, S.prevToken().endPos);
-                cases.append(c);
+            case CASE:
+            case DEFAULT:
+                cases.append(switchBlockStatementGroup());
                 break;
-            }
-            case DEFAULT: {
-                nextToken();
-                accept(COLON);
-                List<JCStatement> stats = blockStatements();
-                JCCase c = F.at(pos).Case(null, stats);
-                if (stats.isEmpty())
-                    storeEnd(c, S.prevToken().endPos);
-                cases.append(c);
-                break;
-            }
             case RBRACE: case EOF:
                 return cases.toList();
             default:
@@ -2152,6 +2187,32 @@
         }
     }
 
+    protected JCCase switchBlockStatementGroup() {
+        int pos = token.pos;
+        List<JCStatement> stats;
+        JCCase c;
+        switch (token.kind) {
+        case CASE:
+            nextToken();
+            JCExpression pat = parseExpression();
+            accept(COLON);
+            stats = blockStatements();
+            c = F.at(pos).Case(pat, stats);
+            if (stats.isEmpty())
+                storeEnd(c, S.prevToken().endPos);
+            return c;
+        case DEFAULT:
+            nextToken();
+            accept(COLON);
+            stats = blockStatements();
+            c = F.at(pos).Case(null, stats);
+            if (stats.isEmpty())
+                storeEnd(c, S.prevToken().endPos);
+            return c;
+        }
+        throw new AssertionError("should not reach here");
+    }
+
     /** MoreStatementExpressions = { COMMA StatementExpression }
      */
     <T extends ListBuffer<? super JCExpressionStatement>> T moreStatementExpressions(int pos,
@@ -2180,10 +2241,15 @@
         } else {
             JCExpression t = term(EXPR | TYPE);
             if ((lastmode & TYPE) != 0 &&
-                (token.kind == IDENTIFIER || token.kind == ASSERT || token.kind == ENUM))
+                (token.kind == IDENTIFIER || token.kind == ASSERT ||
+                 token.kind == ENUM)) {
                 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();
+            }
         }
     }
 
@@ -2387,7 +2453,7 @@
                                                                      JCExpression type,
                                                                      Name name,
                                                                      boolean reqInit,
-                                                                     String dc,
+                                                                     Comment dc,
                                                                      T vdefs)
     {
         vdefs.append(variableDeclaratorRest(pos, mods, type, name, reqInit, dc));
@@ -2403,7 +2469,7 @@
     /** VariableDeclarator = Ident VariableDeclaratorRest
      *  ConstantDeclarator = Ident ConstantDeclaratorRest
      */
-    JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, String dc) {
+    JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, Comment dc) {
         return variableDeclaratorRest(token.pos, mods, type, ident(), reqInit, dc);
     }
 
@@ -2414,7 +2480,7 @@
      *  @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 (token.kind == EQ) {
@@ -2508,7 +2574,7 @@
                 seenImport = true;
                 defs.append(importDeclaration());
             } else {
-                String docComment = token.comment(CommentStyle.JAVADOC);
+                Comment docComment = token.comment(CommentStyle.JAVADOC);
                 if (firstTypeDecl && !seenImport && !seenPackage) {
                     docComment = firstToken.comment(CommentStyle.JAVADOC);
                     consumedToplevelDoc = true;
@@ -2566,7 +2632,7 @@
     /** TypeDeclaration = ClassOrInterfaceOrEnumDeclaration
      *                  | ";"
      */
-    JCTree typeDeclaration(JCModifiers mods, String docComment) {
+    JCTree typeDeclaration(JCModifiers mods, Comment docComment) {
         int pos = token.pos;
         if (mods == null && token.kind == SEMI) {
             nextToken();
@@ -2581,7 +2647,7 @@
      *  @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) {
+    JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, Comment dc) {
         if (token.kind == CLASS) {
             return classDeclaration(mods, dc);
         } else if (token.kind == INTERFACE) {
@@ -2625,7 +2691,7 @@
      *  @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) {
+    protected JCClassDecl classDeclaration(JCModifiers mods, Comment dc) {
         int pos = token.pos;
         accept(CLASS);
         Name name = ident();
@@ -2654,7 +2720,7 @@
      *  @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) {
+    protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
         int pos = token.pos;
         accept(INTERFACE);
         Name name = ident();
@@ -2677,7 +2743,7 @@
      *  @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) {
+    protected JCClassDecl enumDeclaration(JCModifiers mods, Comment dc) {
         int pos = token.pos;
         accept(ENUM);
         Name name = ident();
@@ -2721,8 +2787,8 @@
         if (token.kind == SEMI) {
             nextToken();
             while (token.kind != RBRACE && token.kind != EOF) {
-                defs.appendList(classOrInterfaceBodyDeclaration(enumName,
-                                                                false, false));
+                defs.appendList(classOrInterfaceBodyDeclaration(enumName, false,
+                                                                false));
                 if (token.pos <= endPosTable.errorEndPos) {
                     // error recovery
                    skip(false, true, true, false);
@@ -2736,7 +2802,7 @@
     /** EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ]
      */
     JCTree enumeratorDeclaration(Name enumName) {
-        String dc = token.comment(CommentStyle.JAVADOC);
+        Comment dc = token.comment(CommentStyle.JAVADOC);
         int flags = Flags.PUBLIC|Flags.STATIC|Flags.FINAL|Flags.ENUM;
         if (token.deprecatedFlag()) {
             flags |= Flags.DEPRECATED;
@@ -2820,12 +2886,12 @@
      *    | ModifiersOpt Type Ident
      *      ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest | DefenderMethodDeclaratorRest ";" )
      */
-    List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface, boolean isAnno) {
+    protected List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface, boolean isAnno) {
         if (token.kind == SEMI) {
             nextToken();
             return List.<JCTree>nil();
         } else {
-            String dc = token.comment(CommentStyle.JAVADOC);
+            Comment dc = token.comment(CommentStyle.JAVADOC);
             int pos = token.pos;
             JCModifiers mods = modifiersOpt();
             if (token.kind == CLASS ||
@@ -2905,7 +2971,7 @@
                               Name name,
                               List<JCTypeParameter> typarams,
                               boolean isInterface, boolean isAnno, boolean isVoid,
-                              String dc) {
+                              Comment dc) {
         List<JCVariableDecl> params = formalParameters();
         if (!isVoid) type = bracketsOpt(type);
         List<JCExpression> thrown = List.nil();
@@ -2929,44 +2995,16 @@
                     if (!isInterface) {
                         syntaxError("defender.in.class");
                     }
-                    checkDefenderMethods();
-                    mods.flags |= Flags.DEFENDER;
                     if (token.kind == LBRACE) {
+                        checkDefenderMethods();
+                        mods.flags |= Flags.DEFENDER;
                         //an explicit defender declaration is just a method block
                         body = block();
                     } else {
-                        log.warning(pos, "obsolete.defender.syntax");
-                        //if there's no block, a defender method declaration
-                        //is turned into an ordinary method declaration where the
-                        //method body is a standard method call to the extended method.
-                        //
-                        // e.g.
-                        // extension T reduce(T arg) default Collections.<T>reduce;
-                        //
-                        // --> T reduce(T arg) { Collections.<T>reduce(this, arg); }
-                        int prevMode = mode;
-                        mode = EXPR;
-                        List<JCExpression> defenderMethodParams = List.<JCExpression>of(toP(F.at(pos).Ident(names._this)));
-                        for (JCVariableDecl param : params) {
-                            defenderMethodParams =
-                                    defenderMethodParams.append(toP(F.at(pos).Ident(param.name)));
-                        }
-                        List<JCExpression> args = typeArgumentsOpt();
-                        JCExpression meth = toP(F.at(pos).Ident(ident()));
-                        while (args == null && token.kind == DOT) {
-                            accept(DOT);
-                            args = typeArgumentsOpt(EXPR);
-                            meth = toP(F.at(pos).Select(meth, ident()));
-                        }
-                        JCMethodInvocation defaultImpl = toP(F.at(pos).Apply(args, meth, defenderMethodParams));
-                        JCStatement inlined_body = toP(F.at(pos).Exec(defaultImpl));
-                        if (!isVoid) {
-                            inlined_body = toP(F.at(pos).Return(defaultImpl));
-                        }
-                        body = toP(F.at(pos).Block(0, List.<JCStatement>of(inlined_body)));
+                        //recovery
+                        defaultValue = annotationValue();
                         accept(SEMI);
-                        mode = prevMode;
-                     }
+                    }
                 }
             } else {
                 defaultValue = null;
@@ -3001,7 +3039,10 @@
         return ts.toList();
     }
 
-    /** TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"]
+    /**
+     *  {@literal
+     *  TypeParametersOpt = ["<" TypeParameter {"," TypeParameter} ">"]
+     *  }
      */
     List<JCTypeParameter> typeParametersOpt() {
         if (token.kind == LT) {
@@ -3020,9 +3061,12 @@
         }
     }
 
-    /** TypeParameter = TypeVariable [TypeParameterBound]
+    /**
+     *  {@literal
+     *  TypeParameter = TypeVariable [TypeParameterBound]
      *  TypeParameterBound = EXTENDS Type {"&" Type}
      *  TypeVariable = Ident
+     *  }
      */
     JCTypeParameter typeParameter() {
         int pos = token.pos;
--- a/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -62,19 +62,54 @@
     @Override
     protected Comment processComment(int pos, int endPos, CommentStyle style) {
         char[] buf = reader.getRawCharacters(pos, endPos);
-        return new JavadocComment(new ColReader(fac, buf, buf.length), style);
+        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).
+     * 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 ColReader extends UnicodeReader {
+    static class DocReader extends UnicodeReader {
 
          int col;
+         int startPos;
 
-         ColReader(ScannerFactory fac, char[] input, int inputLength) {
+         /**
+          * 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
@@ -147,19 +182,43 @@
                  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 class JavadocComment extends JavaTokenizer.BasicComment<ColReader> {
+     protected class JavadocComment extends JavaTokenizer.BasicComment<DocReader> {
 
         /**
         * Translated and stripped contents of doc comment
         */
         private String docComment = null;
+        private int[] docPosns = null;
 
-        JavadocComment(ColReader comment_reader, CommentStyle cs) {
-            super(comment_reader, cs);
+        JavadocComment(DocReader reader, CommentStyle cs) {
+            super(reader, cs);
         }
 
+        @Override
         public String getText() {
             if (!scanned && cs == CommentStyle.JAVADOC) {
                 scanDocComment();
@@ -168,6 +227,33 @@
         }
 
         @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 < 0 || pos >= docComment.length())
+                throw new StringIndexOutOfBoundsException();
+            if (docPosns == null)
+                return -1;
+            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 {
@@ -209,7 +295,8 @@
                  // 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:
@@ -263,10 +350,10 @@
                              break outerLoop;
                          }
                      } else if (! firstLine) {
-                         //The current line does not begin with a '*' so we will indent it.
-                         for (int i = 1; i < comment_reader.col; i++) {
-                             comment_reader.putChar(' ', false);
-                         }
+                         // 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.
@@ -334,11 +421,14 @@
 
                      // 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;
--- a/src/share/classes/com/sun/tools/javac/parser/Lexer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/Lexer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -61,7 +61,8 @@
 
     /**
      * Splits the current token in two and return the first (splitted) token.
-     * For instance '<<<' is splitted into two tokens '<' and '<<' respectively,
+     * For instance {@literal '<<<'} is split into two tokens
+     * {@literal '<'} and {@literal '<<'} respectively,
      * and the latter is returned.
      */
     Token split();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/parser/SimpleDocCommentTable.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,67 @@
+/*
+ * 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.HashMap;
+import java.util.Map;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DocCommentTable;
+import com.sun.tools.javac.tree.JCTree;
+
+
+/**
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends 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 SimpleDocCommentTable implements DocCommentTable {
+    Map<JCTree, Comment> table;
+
+    SimpleDocCommentTable() {
+        table = new HashMap<JCTree, Comment>();
+    }
+
+    public boolean hasComment(JCTree tree) {
+        return table.containsKey(tree);
+    }
+
+    public Comment getComment(JCTree tree) {
+        return table.get(tree);
+    }
+
+    public String getCommentText(JCTree tree) {
+        Comment c = getComment(tree);
+        return (c == null) ? null : c.getText();
+    }
+
+    public void putComment(JCTree tree, Comment c) {
+        table.put(tree, c);
+    }
+
+}
--- a/src/share/classes/com/sun/tools/javac/parser/Tokens.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/Tokens.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -177,7 +177,7 @@
         FALSE("false", Tag.NAMED),
         NULL("null", Tag.NAMED),
         ARROW("->"),
-        HASH("#"),
+        COLCOL("::"),
         LPAREN("("),
         RPAREN(")"),
         LBRACE("{"),
@@ -195,7 +195,6 @@
         TILDE("~"),
         QUES("?"),
         COLON(":"),
-        COLCOL("::"),
         EQEQ("=="),
         LTEQ("<="),
         GTEQ(">="),
@@ -295,6 +294,7 @@
         }
 
         String getText();
+        int getSourcePos(int index);
         CommentStyle getStyle();
         boolean isDeprecated();
     }
@@ -372,11 +372,11 @@
          * Preserve classic semantics - if multiple javadocs are found on the token
          * the last one is returned
          */
-        public String comment(Comment.CommentStyle style) {
-            List<Comment> readers = getReaders(Comment.CommentStyle.JAVADOC);
-            return readers.isEmpty() ?
+        public Comment comment(Comment.CommentStyle style) {
+            List<Comment> comments = getComments(Comment.CommentStyle.JAVADOC);
+            return comments.isEmpty() ?
                     null :
-                    readers.head.getText();
+                    comments.head;
         }
 
         /**
@@ -384,22 +384,22 @@
          * javadoc comment attached to this token contains the '@deprecated' string
          */
         public boolean deprecatedFlag() {
-            for (Comment r : getReaders(Comment.CommentStyle.JAVADOC)) {
-                if (r.isDeprecated()) {
+            for (Comment c : getComments(Comment.CommentStyle.JAVADOC)) {
+                if (c.isDeprecated()) {
                     return true;
                 }
             }
             return false;
         }
 
-        private List<Comment> getReaders(Comment.CommentStyle style) {
+        private List<Comment> getComments(Comment.CommentStyle style) {
             if (comments == null) {
                 return List.nil();
             } else {
                 ListBuffer<Comment> buf = ListBuffer.lb();
-                for (Comment r : comments) {
-                    if (r.getStyle() == style) {
-                        buf.add(r);
+                for (Comment c : comments) {
+                    if (c.getStyle() == style) {
+                        buf.add(c);
                     }
                 }
                 return buf.toList();
--- a/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -25,13 +25,15 @@
 
 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.Log;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 
-import java.nio.CharBuffer;
-
 import static com.sun.tools.javac.util.LayoutCharacters.*;
 
 /** The char reader used by the javac lexer/tokenizer. Returns the sequence of
@@ -91,9 +93,7 @@
             if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) {
                 inputLength--;
             } else {
-                char[] newInput = new char[inputLength + 1];
-                System.arraycopy(input, 0, newInput, 0, input.length);
-                input = newInput;
+                input = Arrays.copyOf(input, inputLength + 1);
             }
         }
         buf = input;
@@ -130,11 +130,7 @@
     /** Append a character to sbuf.
      */
     protected void putChar(char ch, boolean scan) {
-        if (sp == sbuf.length) {
-            char[] newsbuf = new char[sbuf.length * 2];
-            System.arraycopy(sbuf, 0, newsbuf, 0, sbuf.length);
-            sbuf = newsbuf;
-        }
+        sbuf = ArrayUtils.ensureCapacity(sbuf, sp);
         sbuf[sp++] = ch;
         if (scan)
             scanChar();
--- a/src/share/classes/com/sun/tools/javac/processing/JavacMessager.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacMessager.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 @@
         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,7 +132,8 @@
                 break;
             }
         } finally {
-            if (oldSource != null)
+            // reinstate the saved version, only if it was saved earlier
+            if (newSource != null)
                 log.useSource(oldSource);
         }
     }
--- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -49,7 +49,7 @@
 
 import com.sun.source.util.JavacTask;
 import com.sun.source.util.TaskEvent;
-import com.sun.tools.javac.api.JavacTaskImpl;
+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.*;
@@ -97,11 +97,9 @@
     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;
@@ -167,12 +165,14 @@
         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.
@@ -462,7 +462,7 @@
      * 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.
      */
@@ -882,7 +882,9 @@
         /** Create the compiler to be used for the final compilation. */
         JavaCompiler finalCompiler(boolean errorStatus) {
             try {
-                JavaCompiler c = JavaCompiler.instance(nextContext());
+                Context nextCtx = nextContext();
+                JavacProcessingEnvironment.this.context = nextCtx;
+                JavaCompiler c = JavaCompiler.instance(nextCtx);
                 c.log.nwarnings += compiler.log.nwarnings;
                 if (errorStatus) {
                     c.log.nerrors += compiler.log.nerrors;
@@ -1021,7 +1023,7 @@
         }
 
         /** Get the context for the next round of processing.
-         * Important values are propogated from round to round;
+         * Important values are propagated from round to round;
          * other values are implicitly reset.
          */
         private Context nextContext() {
@@ -1072,8 +1074,10 @@
             Assert.checkNonNull(tokens);
             next.put(Tokens.tokensKey, tokens);
 
+            Log nextLog = Log.instance(next);
             // propogate the log's writers directly, instead of going through context
-            Log.instance(next).setWriters(log);
+            nextLog.setWriters(log);
+            nextLog.setSourceMap(log);
 
             JavaCompiler oldCompiler = JavaCompiler.instance(context);
             JavaCompiler nextCompiler = JavaCompiler.instance(next);
@@ -1084,10 +1088,11 @@
             elementUtils.setContext(next);
             typeUtils.setContext(next);
 
-            JavacTaskImpl task = (JavacTaskImpl) context.get(JavacTask.class);
+            JavacTask task = context.get(JavacTask.class);
             if (task != null) {
                 next.put(JavacTask.class, task);
-                task.updateContext(next);
+                if (task instanceof BasicJavacTask)
+                    ((BasicJavacTask) task).updateContext(next);
             }
 
             JavacTrees trees = context.get(JavacTrees.class);
@@ -1187,14 +1192,7 @@
             return compiler;
         }
 
-        if (procOnly && !foundTypeProcessors) {
-            compiler.todo.clear();
-        } else {
-            if (procOnly && foundTypeProcessors)
-                compiler.shouldStopPolicy = CompileState.FLOW;
-
-            compiler.enterTrees(roots);
-        }
+        compiler.enterTreesIfNeeded(roots);
 
         return compiler;
     }
@@ -1362,7 +1360,8 @@
      * {@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;
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Oct 25 23:25:08 2012 +0100
@@ -137,6 +137,10 @@
 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
 
@@ -144,13 +148,8 @@
 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\
-    required: {2}\n\
-    found: {3}
-
-# 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\
     required: {2}\n\
     found: {3}\n\
@@ -160,15 +159,10 @@
 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.misc.cant.apply.symbol=\
     {0} {1} in {4} {5} cannot be applied to given types\n\
     required: {2}\n\
-    found: {3}
-
-# 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.1=\
-    {0} {1} in {4} {5} cannot be applied to given types;\n\
-    required: {2}\n\
     found: {3}\n\
     reason: {6}
 
@@ -176,37 +170,58 @@
 compiler.misc.cant.apply.symbols=\
     no suitable {0} found for {1}({2})
 
-compiler.misc.cyclic.lambda.inference=\
-    cyclic inference - cannot infer target type for given lambda/method reference expression
-
-compiler.misc.no.target.method.for.lambda.conv=\
-    no target method for lambda conversion found in {0} {1}
-
-compiler.misc.incompatible.targets.for.lambda.conv=\
+# 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.misc.invalid.generic.target.for.lambda.conv=\
-    invalid target for lambda conversion: method {0} in {1} {2} is generic
-
-compiler.misc.target.for.lambda.conv.must.be.interface=\
-    the target type of a lambda conversion must be an interface
-
-compiler.misc.no.suitable.sam.inst=\
-    no instance of type {0} exists so that lambda expression can be type-checked
-
-compiler.err.invalid.reference=\
-    invalid {0} reference ; {1}
-
-compiler.misc.invalid.reference=\
-    invalid {0} reference ; {1}
+compiler.misc.not.a.functional.intf=\
+    the target type must be a functional interface
+
+# 0: message segment
+compiler.misc.not.a.functional.intf.1=\
+    the target type must be a functional interface\n\
+    {0}
+
+# 0: symbol, 1: symbol kind, 2: symbol
+compiler.misc.invalid.generic.desc.in.functional.intf=\
+    invalid functional descriptor: 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: symbol kind, 1: message segment
+compiler.err.invalid.mref=\
+    invalid {0} reference; {1}
+
+# 0: symbol kind, 1: message segment
+compiler.misc.invalid.mref=\
+    invalid {0} reference; {1}
 
 # 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 variable {0} cannot be referenced\n\
-    local variables referenced from {1} must be ''effectively final''
+    local variables referenced from {1} must be final or effectively final
+
 
 compiler.misc.lambda=\
     a lambda expression
@@ -214,12 +229,6 @@
 compiler.misc.inner.cls=\
     an inner class
 
-compiler.err.break.inside.lambda=\
-    ''break'' outside the scope of a lambda expression
-
-compiler.err.cont.inside.lambda=\
-    ''continue'' outside the scope of a lambda expression
-
 # 0: type
 compiler.err.cant.deref=\
     {0} cannot be dereferenced
@@ -249,6 +258,9 @@
 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
 
@@ -274,6 +286,9 @@
 compiler.err.concrete.inheritance.conflict=\
     methods {0} from {1} and {2} from {3} are inherited with the same signature
 
+compiler.err.default.allowed.in.intf.annotation.member=\
+    default value only allowed in an @interface member
+
 # 0: symbol
 compiler.err.doesnt.exist=\
     package {0} does not exist
@@ -285,6 +300,70 @@
 compiler.err.duplicate.annotation.member.value=\
     duplicate annotation member value {0} in {1}
 
+# 0: type
+compiler.err.duplicate.annotation.missing.container=\
+    duplicate annotation, the declaration of {0} does not have a ContainedBy annotation
+
+# 0: type, 1: type
+compiler.err.invalid.container.no.containedby=\
+    invalid contained repeatable annotation, {0} is not annotated with {1}
+
+# 0: type, 1: type
+compiler.err.invalid.container.wrong.containedby=\
+    invalid contained repeatable annotation, {0} does not match {1}
+
+# 0: type, 1: type
+compiler.err.invalid.container.no.containerfor=\
+    invalid container for repeating annotations, {0} is not annotated with {1}
+
+# 0: type, 1: type
+compiler.err.invalid.container.wrong.containerfor=\
+    invalid container for repeating annotations, {0} does not match {1}
+
+# 0: type
+compiler.err.invalid.containedby.annotation=\
+    duplicate annotation, {0} is annotated with an invalid ContainedBy annotation
+
+# 0: type
+compiler.err.invalid.containedby.annotation.no.value=\
+    duplicate annotation, {0} is not a valid ContainedBy, no value element method declared
+
+# 0: type, 1: number
+compiler.err.invalid.containedby.annotation.multiple.values=\
+    duplicate annotation, {0} is not a valid ContainedBy, {1} value element methods declared
+
+# 0: type
+compiler.err.invalid.containedby.annotation.invalid.value=\
+    duplicate annotation, {0} is not a valid ContainedBy, invalid value element, need a method
+
+# 0: type, 1: type, 2: type
+compiler.err.invalid.containedby.annotation.value.return=\
+    duplicate annotation, value element of containing annotation {0} should have type {2}, found {1}
+
+# 0: type, 1: symbol
+compiler.err.invalid.containedby.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.containedby.annotation.retention=\
+    containing annotation {0} has shorter retention ({1}) than the contained annotation {2} with retention {3}
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.containedby.annotation.not.documented=\
+    containing annotation type, {0}, is not @Documented while repeated annotation type, {1}, is
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.containedby.annotation.not.inherited=\
+    containing annotation type, {0}, is not @Inherited while repeated annotation type, {1}, is
+
+# 0: symbol, 1: symbol
+compiler.err.invalid.containedby.annotation.incompatible.target=\
+    target of container annotation {0} is not a subset of target of repeated annotation {1}
+
+# 0: symbol
+compiler.err.invalid.containedby.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}
@@ -373,11 +452,6 @@
 compiler.err.generic.throwable=\
     a generic class may not extend java.lang.Throwable
 
-compiler.err.must.be.throwable=\
-    bad type in thrown expression\n\
-    found: {0}\n\
-    required: java.lang.Throwable
-
 # 0: symbol
 compiler.err.icls.cant.have.static.decl=\
     Illegal static declaration in inner class {0}\n\
@@ -440,6 +514,9 @@
 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
 
@@ -498,6 +575,9 @@
 compiler.err.varargs.and.old.array.syntax=\
     legacy array notation not allowed on variable-arity parameter
 
+compiler.err.variable.not.allowed=\
+    variable declaration not allowed here
+
 # 0: name
 compiler.err.label.already.in.use=\
     label {0} already in use
@@ -608,20 +688,32 @@
     second operand: {0}\n\
     third operand : {1}
 
+# 0: message segment
 compiler.misc.incompatible.type.in.conditional=\
     bad type in conditional expression; {0}
 
 compiler.misc.conditional.target.cant.be.void=\
     target-type for conditional expression cannot be void
 
-compiler.misc.infer.incompatible.ret.types.in.lambda=\
+# 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.lambda=\
     incompatible thrown types {0} in lambda expression
 
-compiler.misc.infer.incompatible.arg.types.in.lambda=\
+# 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.err.new.not.allowed.in.annotation=\
@@ -646,9 +738,11 @@
 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
@@ -751,8 +845,10 @@
 
 # 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, both {1} {2} in {3} and {4} {5} in {6} match
 
@@ -1414,10 +1510,6 @@
 compiler.warn.varargs.redundant.trustme.anno=\
     Redundant {0} annotation. {1}
 
-compiler.warn.obsolete.defender.syntax=\
-    This version of the extension method syntax is deprecated and might be disallowed in future versions of the compiler.\n\
-    Use an inlined body instead.
-
 #####
 
 ## The following are tokens which are non-terminals in the language. They should
@@ -1715,6 +1807,10 @@
     inferred: {0}\n\
     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=\
     {0}<>
@@ -1754,6 +1850,7 @@
 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
 
@@ -1767,7 +1864,7 @@
 compiler.err.unexpected.lambda=\
    lambda expression not expected here
 
-compiler.err.unexpected.meth.reference=\
+compiler.err.unexpected.mref=\
    method reference not expected here
 
 compiler.err.defender.in.class=\
@@ -1812,6 +1909,8 @@
     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\
@@ -2128,15 +2227,6 @@
 compiler.misc.type.null=\
     <null>
 
-compiler.misc.type.lambda=\
-    lambda
-
-compiler.misc.type.mref=\
-    member reference
-
-compiler.misc.type.conditional=\
-    conditional expression
-
 # X#n (where n is an int id) is disambiguated tvar name
 # 0: name, 1: number
 compiler.misc.type.var=\
@@ -2172,9 +2262,16 @@
 
 # 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
--- a/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/sym/CreateSymbols.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -206,9 +206,7 @@
             }
             ClassSymbol cs = (ClassSymbol) sym;
             if (addLegacyAnnotation) {
-                cs.attributes_field = (cs.attributes_field == null)
-                    ? List.of(proprietary)
-                    : cs.attributes_field.prepend(proprietary);
+                cs.annotations.prepend(List.of(proprietary));
             }
             writeClass(pool, cs, writer);
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.javac.tree;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+
+/**
+ * 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);
+
+    /**
+     * Set the Comment to be associated with a tree node.
+     */
+    public void putComment(JCTree tree, Comment c);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/tree/EndPosTable.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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);
+}
--- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -25,25 +25,23 @@
 
 package com.sun.tools.javac.tree;
 
+import java.io.IOException;
+import java.io.StringWriter;
 import java.util.*;
 
-import java.io.IOException;
-import java.io.StringWriter;
 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.tools.javac.parser.EndPosTable;
-import com.sun.source.tree.*;
-import com.sun.source.tree.LambdaExpressionTree.BodyKind;
-import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
-
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.List;
 import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
@@ -491,7 +489,7 @@
         public ImportScope namedImportScope;
         public StarImportScope starImportScope;
         public Position.LineMap lineMap = null;
-        public Map<JCTree, String> docComments = null;
+        public DocCommentTable docComments = null;
         public EndPosTable endPositions = null;
         protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
                         JCExpression pid,
@@ -1850,8 +1848,6 @@
             BOUND(ReferenceMode.INVOKE, false),
             /** Expr # staticMethod */
             STATIC_EVAL(ReferenceMode.INVOKE, false),
-            /** Outer.Inner # new */
-            UNBOUND_INNER(ReferenceMode.NEW, true),
             /** Inner # new */
             IMPLICIT_INNER(ReferenceMode.NEW, false),
             /** Toplevel # new */
@@ -2067,7 +2063,7 @@
     }
 
     /**
-     * A parameterized type, T<...>
+     * A parameterized type, {@literal T<...>}
      */
     public static class JCTypeApply extends JCExpression implements ParameterizedTypeTree {
         public JCExpression clazz;
--- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -29,14 +29,12 @@
 import java.util.*;
 
 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.parser.Tokens.Comment;
+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.code.*;
-
-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.tree.JCTree.Tag.*;
@@ -78,10 +76,21 @@
      */
     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.
      */
@@ -130,8 +139,12 @@
     public void println() throws IOException {
         out.write(lineSep);
     }
-    
-    public static String toSimpleString(JCTree tree, int length) {
+
+    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);
@@ -141,19 +154,14 @@
             // 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().replaceAll("\\s+", " ").replaceAll("/\\*missing\\*/", "");
-        if (res.length() < (length * 3)) {
+        if (res.length() < maxLength) {
             return res;
         } else {
-            StringBuilder buf = new StringBuilder();
-            for (int i = 0; i < 2 * length; i++) {
-                buf.append(res.charAt(i));
-            }
-            buf.append("[...]");
-            for (int i = res.length() - length; i < res.length() ; i++) {
-                buf.append(res.charAt(i));
-            }
-            return buf.toString();
+            int split = (maxLength - trimSequence.length()) * 2 / 3;
+            return res.substring(0, split) + trimSequence + res.substring(split);
         }
     }
 
@@ -259,7 +267,7 @@
      */
     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;
@@ -284,7 +292,8 @@
         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()) {
@@ -506,7 +515,7 @@
 
     public void visitVarDef(JCVariableDecl tree) {
         try {
-            if (docComments != null && docComments.get(tree) != null) {
+            if (docComments != null && docComments.hasComment(tree)) {
                 println(); align();
             }
             printDocComment(tree);
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Oct 25 23:25:08 2012 +0100
@@ -25,15 +25,14 @@
 
 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 com.sun.tools.javac.tree.JCTree.*;
 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.parser.EndPosTable;
-import com.sun.tools.javac.tree.JCTree.*;
-
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK;
@@ -246,23 +245,33 @@
             default: return false;
         }
     }
-    
-    /** Return true if a tree represents a diamond new expr. */
-    public static boolean isPoly(JCTree tree) {
-        switch(tree.getTag()) {
+
+    public static boolean isEnumInit(JCTree tree) {
+        switch (tree.getTag()) {
+            case VARDEF:
+                return (((JCVariableDecl)tree).mods.flags & ENUM) != 0;
+            default:
+                return false;
+        }
+    }
+
+    /** Return true if a a tree corresponds to a poly expression. */
+    public static boolean isPoly(JCTree tree, JCTree origin) {
+        switch (tree.getTag()) {
             case APPLY:
             case NEWCLASS:
             case CONDEXPR:
+                return !origin.hasTag(TYPECAST);
             case LAMBDA:
             case REFERENCE:
                 return true;
             case PARENS:
-                return isPoly(((JCParens)tree).expr);
+                return isPoly(((JCParens)tree).expr, origin);
             default:
                 return false;
         }
     }
-    
+
     public static boolean isExplicitLambda(JCLambda lambda) {
         return lambda.params.isEmpty() ||
                 lambda.params.head.vartype != null;
@@ -304,6 +313,13 @@
         return (lit.typetag == TypeTags.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);
+    }
+
     /** The position of the first statement in a block, or the position of
      *  the block itself if it is empty.
      */
@@ -324,9 +340,8 @@
             return endPos(((JCSynchronized) tree).body);
         else if (tree.hasTag(TRY)) {
             JCTry t = (JCTry) tree;
-            return endPos((t.finalizer != null)
-                          ? t.finalizer
-                          : t.catchers.last().body);
+            return endPos((t.finalizer != null) ? t.finalizer
+                          : (t.catchers.nonEmpty() ? t.catchers.last().body : t.body));
         } else
             return tree.pos;
     }
--- a/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -87,7 +87,7 @@
 
     /** Create a tree maker with a given toplevel and FIRSTPOS as initial position.
      */
-    TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) {
+    protected TreeMaker(JCCompilationUnit toplevel, Names names, Types types, Symtab syms) {
         this.pos = Position.FIRSTPOS;
         this.toplevel = toplevel;
         this.names = names;
@@ -740,7 +740,7 @@
             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);
--- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -43,8 +43,10 @@
 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.tree.JCTree.*;
 
 import com.sun.tools.javac.file.BaseFileObject;
+import com.sun.tools.javac.tree.Pretty;
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
 
 /**
@@ -180,6 +182,9 @@
             }
             return s;
         }
+        else if (arg instanceof JCExpression) {
+            return expr2String((JCExpression)arg);
+        }
         else if (arg instanceof Iterable<?>) {
             return formatIterable(d, (Iterable<?>)arg, l);
         }
@@ -199,6 +204,20 @@
             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.
@@ -489,8 +508,8 @@
      * type referred by a given captured type C contains C itself) which might
      * lead to infinite loops.
      */
-    protected Printer printer = new Printer(isRaw()) {
-        
+    protected Printer printer = new Printer() {
+
         @Override
         protected String localize(Locale locale, String key, Object... args) {
             return AbstractDiagnosticFormatter.this.localize(locale, key, args);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,87 @@
+/*
+ * 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.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;
+        }
+    }
+}
--- a/src/share/classes/com/sun/tools/javac/util/Bits.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Bits.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -25,6 +25,8 @@
 
 package com.sun.tools.javac.util;
 
+import java.util.Arrays;
+
 /** A class for extensible, mutable bit sets.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -62,9 +64,7 @@
 
     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);
         }
     }
 
@@ -127,7 +127,7 @@
             (bits[x >>> wordshift] & (1 << (x & wordmask))) != 0;
     }
 
-    /** this set = this set & xs.
+    /** {@literal this set = this set & xs}.
      */
     public Bits andSet(Bits xs) {
         sizeTo(xs.bits.length);
@@ -179,12 +179,12 @@
         return n - (x&1);
     }
 
-    /** Return the index of the least bit position >= x that is set.
+    /** Return the index of the least bit position &ge; 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) {
         int windex = x >>> wordshift;
--- a/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/ByteBuffer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 @@
         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 @@
      *  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 @@
     /** 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 @@
     /** 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);
--- a/src/share/classes/com/sun/tools/javac/util/Context.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Context.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -115,7 +115,10 @@
      * 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. */
--- a/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -32,7 +32,7 @@
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 
 import static com.sun.tools.javac.util.LayoutCharacters.*;
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -35,7 +35,7 @@
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
 import com.sun.tools.javac.code.Lint.LintCategory;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
--- a/src/share/classes/com/sun/tools/javac/util/List.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/List.java	Thu Oct 25 23:25:08 2012 +0100
@@ -86,9 +86,10 @@
     /** 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.equals(elem)) {
+            if (a != null && !a.equals(elem)) {
                 res = res.prepend(a);
             }
         }
@@ -131,8 +132,8 @@
                 xs = new List<A>(array[i], xs);
         return xs;
     }
-    
-    public static <A> List<A> from(Collection<A> coll) {
+
+    public static <A> List<A> from(Iterable<? extends A> coll) {
         List<A> xs = nil();
         for (A a : coll) {
             xs = new List<A>(a, xs);
--- a/src/share/classes/com/sun/tools/javac/util/Log.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -37,7 +37,7 @@
 import com.sun.tools.javac.api.DiagnosticFormatter;
 import com.sun.tools.javac.main.Main;
 import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 
@@ -301,6 +301,10 @@
         this.errWriter = other.errWriter;
     }
 
+    public void setSourceMap(Log other) {
+        this.sourceMap = other.sourceMap;
+    }
+
     /** Flush the logs
      */
     public void flush() {
@@ -546,7 +550,7 @@
             throw new Error();
         }
     }
-    
+
     public void deferAll() {
         deferredDiagFilter = new Filter<JCDiagnostic>() {
             public boolean accepts(JCDiagnostic t) {
@@ -554,7 +558,7 @@
             }
         };
     }
-    
+
     public void deferNone() {
         deferredDiagFilter = null;
     }
--- a/src/share/classes/com/sun/tools/javac/util/Name.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Name.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -43,28 +43,28 @@
     }
 
     /**
-     * @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);
@@ -142,6 +142,7 @@
 
     /** Return the string representation of this name.
      */
+    @Override
     public String toString() {
         return Convert.utf2string(getByteArray(), getByteOffset(), getByteLength());
     }
--- a/src/share/classes/com/sun/tools/javac/util/Names.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Names.java	Thu Oct 25 23:25:08 2012 +0100
@@ -118,6 +118,7 @@
     // 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 Code;
@@ -187,7 +188,6 @@
     public final Name _className;
     public final Name _methodName;
     public final Name _methodSignature;
-    public final Name BootstrapMethods;
 
     public final Name.Table table;
 
@@ -266,6 +266,7 @@
         // attribute names
         Annotation = fromString("Annotation");
         AnnotationDefault = fromString("AnnotationDefault");
+        BootstrapMethods = fromString("BootstrapMethods");
         Bridge = fromString("Bridge");
         CharacterRangeTable = fromString("CharacterRangeTable");
         Code = fromString("Code");
@@ -336,7 +337,6 @@
         fromMethodDescriptorString = fromString("fromMethodDescriptorString");
         findStatic = fromString("findStatic");
         insertArguments = fromString("insertArguments");
-        BootstrapMethods = fromString("BootstrapMethods");
     }
 
     protected Name.Table createTable(Options options) {
--- a/src/share/classes/com/sun/tools/javac/util/Position.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Position.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -79,12 +79,12 @@
     }
 
     /** 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 @@
          * @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 @@
          *
          * @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);
 
--- a/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/RawDiagnosticFormatter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -32,6 +32,7 @@
 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.*;
@@ -117,16 +118,17 @@
     @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
--- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -540,13 +540,22 @@
                                          bounds.head.tag == NONE ||
                                          bounds.head.tag == 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;
         }
--- a/src/share/classes/com/sun/tools/javac/util/SharedNameTable.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/SharedNameTable.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 @@
     @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 @@
         }
         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;
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -83,7 +83,7 @@
 
         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) {
--- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Oct 25 23:25:08 2012 +0100
@@ -279,7 +279,7 @@
     }
 
     public boolean isFunctionalInterface() {
-        return env.types.isSam(tsym);
+        return env.types.isFunctionalInterface(tsym);
     }
 
     /**
--- a/src/share/classes/com/sun/tools/javadoc/Comment.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/Comment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -386,7 +386,7 @@
     }
 
     /**
-     * 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.
--- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -138,7 +138,7 @@
     /**
      * 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 &#64;see tags.
      */
     public SeeTag[] seeTags() {
         return comment().seeTags();
--- a/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -241,7 +241,7 @@
      * Return the serialField tags in this FieldDocImpl item.
      *
      * @return an array of <tt>SerialFieldTagImpl</tt> containing all
-     *         <code>&#64serialField</code> tags.
+     *         <code>&#64;serialField</code> tags.
      */
     public SerialFieldTag[] serialFieldTags() {
         return comment().serialFieldTags();
--- a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -25,14 +25,17 @@
 
 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.tree.TreeInfo;
+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
@@ -77,7 +80,7 @@
     public void visitTopLevel(JCCompilationUnit tree) {
         super.visitTopLevel(tree);
         if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
-            String comment = tree.docComments.get(tree);
+            String comment = TreeInfo.getCommentText(env, tree);
             docenv.makePackageDoc(tree.packge, comment, tree);
         }
     }
@@ -87,7 +90,7 @@
         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);
+            String comment = TreeInfo.getCommentText(env, tree);
             ClassSymbol c = tree.sym;
             docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
         }
--- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,13 +25,14 @@
 
 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.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.tree.TreeInfo;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Position;
 
 /**
  *  Javadoc's own memberEnter phase does a few things above and beyond that
@@ -61,11 +62,12 @@
         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);
+        String docComment = TreeInfo.getCommentText(env, tree);
         Position.LineMap lineMap = env.toplevel.lineMap;
         if (meth.isConstructor())
             docenv.makeConstructorDoc(meth, docComment, tree, lineMap);
@@ -75,12 +77,13 @@
             docenv.makeMethodDoc(meth, docComment, tree, lineMap);
     }
 
+    @Override
     public void visitVarDef(JCVariableDecl tree) {
         super.visitVarDef(tree);
         if (tree.sym != null &&
                 tree.sym.kind == Kinds.VAR &&
                 !isParameter(tree.sym)) {
-            String docComment = env.toplevel.docComments.get(tree);
+            String docComment = TreeInfo.getCommentText(env, tree);
             Position.LineMap lineMap = env.toplevel.lineMap;
             docenv.makeFieldDoc(tree.sym, docComment, tree, lineMap);
         }
--- a/src/share/classes/com/sun/tools/javah/JavahTask.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javah/JavahTask.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, 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
@@ -79,7 +79,7 @@
 
 /**
  * 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
@@ -506,7 +506,7 @@
         List<String> opts = new ArrayList<String>();
         opts.add("-proc:only");
         opts.addAll(javac_extras);
-        CompilationTask t = c.getTask(log, fileManager, diagnosticListener, opts, internalize(classes), null);
+        CompilationTask t = c.getTask(log, fileManager, diagnosticListener, opts, classes, null);
         JavahProcessor p = new JavahProcessor(g);
         t.setProcessors(Collections.singleton(p));
 
@@ -516,14 +516,6 @@
         return ok;
     }
 
-    private List<String> internalize(List<String> classes) {
-        List<String> l = new ArrayList<String>();
-        for (String c: classes) {
-            l.add(c.replace('$', '.'));
-        }
-        return l;
-    }
-
     private List<File> pathToFiles(String path) {
         List<File> files = new ArrayList<File>();
         for (String f: path.split(File.pathSeparator)) {
--- a/src/share/classes/com/sun/tools/javap/CodeWriter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, 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
@@ -45,8 +45,8 @@
  *  This code and its internal interfaces are subject to change or
  *  deletion without notice.</b>
  */
-class CodeWriter extends BasicWriter {
-    static CodeWriter instance(Context context) {
+public class CodeWriter extends BasicWriter {
+    public static CodeWriter instance(Context context) {
         CodeWriter instance = context.get(CodeWriter.class);
         if (instance == null)
             instance = new CodeWriter(context);
--- a/src/share/classes/com/sun/tools/javap/JavapTask.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javap/JavapTask.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2009, 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
@@ -374,8 +374,8 @@
         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 +383,7 @@
     }
 
     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) {
--- a/src/share/classes/com/sun/tools/javap/StackMapWriter.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/com/sun/tools/javap/StackMapWriter.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -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 @@
             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;
--- a/src/share/classes/javax/lang/model/util/Elements.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/javax/lang/model/util/Elements.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -79,12 +79,12 @@
      *
      * <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>*&#47;</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>*&#47;</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
--- a/src/share/classes/javax/tools/JavaCompiler.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/src/share/classes/javax/tools/JavaCompiler.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -137,7 +137,7 @@
  *       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());
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testHelpFile/TestHelpFile.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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      7132631
+ * @summary  Make sure that the help file is generated correctly.
+ * @author   Bhavesh Patel
+ * @library  ../lib/
+ * @build    JavadocTester TestHelpFile
+ * @run main TestHelpFile
+ */
+
+public class TestHelpFile extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "7132631";
+
+    //Javadoc arguments.
+    private static final String[] ARGS = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR,
+            SRC_DIR + FS + "TestHelpFile.java"
+    };
+
+    private static final String[][] NEGATED_TEST = NO_TEST;
+
+    private static final String[][] TEST = {
+        {BUG_ID + FS + "help-doc.html",
+            "<a href=\"constant-values.html\">Constant Field Values</a>"
+        },
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestHelpFile tester = new TestHelpFile();
+        run(tester, ARGS, TEST, NEGATED_TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testSinceTag/TestSinceTag.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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      7180906
+ * @summary  Test to make sure that the since tag works correctly
+ * @author   Bhavesh Patel
+ * @library  ../lib/
+ * @build    JavadocTester TestSinceTag
+ * @run main TestSinceTag
+ */
+
+public class TestSinceTag extends JavadocTester {
+
+    //Test information.
+    private static final String BUG_ID = "7180906";
+
+    //Javadoc arguments.
+    private static final String[] ARGS1 = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "pkg1"
+    };
+
+    private static final String[] ARGS2 = new String[] {
+        "-d", BUG_ID, "-sourcepath", SRC_DIR, "-nosince", "pkg1"
+    };
+
+    //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>"
+        },
+        {BUG_ID + FS + "serialized-form.html",
+            "<dl><dt><span class=\"strong\">Since:</span></dt>" + NL +
+            "  <dd>1.4</dd>"
+        }
+    };
+
+    /**
+     * The entry point of the test.
+     * @param args the array of command line arguments.
+     */
+    public static void main(String[] args) {
+        TestSinceTag tester = new TestSinceTag();
+        run(tester, ARGS1, TEST, NO_TEST);
+        run(tester, ARGS2, NO_TEST, TEST);
+        tester.printSummary();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getBugName() {
+        return getClass().getName();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testSinceTag/pkg1/C1.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 pkg1;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+/**
+ * A class comment for testing.
+ *
+ * @author      Bhavesh Patel
+ * @since       JDK1.0
+ */
+public class C1 implements Serializable {
+
+    /**
+     * This field indicates whether the C1 is undecorated.
+     *
+     * @see #setUndecorated(boolean)
+     * @since 1.4
+     * @serial
+     * @deprecated As of JDK version 1.5, replaced by
+     * {@link C1#setUndecorated(boolean) setUndecorated(boolean)}.
+     */
+    @Deprecated
+    public boolean undecorated = false;
+
+    /**
+     * This enum specifies the possible modal exclusion types.
+     *
+     * @since 1.6
+     */
+    public static enum ModalExclusionType {
+
+        /**
+         * No modal exclusion.
+         */
+        NO_EXCLUDE,
+        /**
+         * <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
+         * won't be blocked by any application-modal dialogs. Also, it isn't
+         * blocked by document-modal dialogs from outside of its child hierarchy.
+         */
+        APPLICATION_EXCLUDE
+    };
+
+    /**
+     * Constructor.
+     *
+     * @param title the title
+     * @param test boolean value
+     * @exception IllegalArgumentException if the <code>owner</code>'s
+     *     <code>GraphicsConfiguration</code> is not from a screen device
+     * @exception HeadlessException
+     */
+    public C1(String title, boolean test) {
+    }
+
+    public C1(String title) {
+    }
+
+    /**
+     * Method comments.
+     * @param  undecorated <code>true</code> if no decorations are
+     *         to be enabled;
+     *         <code>false</code> if decorations are to be enabled.
+     * @see    #readObject()
+     * @since 1.4
+     */
+    public void setUndecorated(boolean undecorated) {
+        /* Make sure we don't run in the middle of peer creation.*/
+    }
+
+    /**
+     * @see #setUndecorated(boolean)
+     */
+    public void readObject() throws IOException {
+    }
+}
--- a/test/com/sun/javadoc/testUseOption/TestUseOption.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/com/sun/javadoc/testUseOption/TestUseOption.java	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2011, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4496290 4985072 7006178
+ * @bug 4496290 4985072 7006178 7068595
  * @summary A simple test to determine if -use works.
  * @author jamieh
  * @library ../lib/
@@ -34,7 +34,7 @@
 
 public class TestUseOption extends JavadocTester {
 
-    private static final String BUG_ID = "4496290-4985072-7006178";
+    private static final String BUG_ID = "4496290-4985072-7006178-7068595";
 
     //Input for string search tests.
     private static final String[] TEST2 = {
@@ -64,6 +64,13 @@
         }
     };
 
+    private static final String[][] TEST4 = {
+        {BUG_ID + "-4" + FS + "pkg2" + FS + "class-use" + FS + "C3.html", "<a href=" +
+                 "\"../../index.html?pkg2/class-use/C3.html\" target=\"_top\">" +
+                 "Frames</a></li>"
+        }
+    };
+
     private static final String[] ARGS = new String[] {
         "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
     };
@@ -76,6 +83,10 @@
         "-d", BUG_ID + "-3", "-sourcepath", SRC_DIR, "-use", SRC_DIR + FS + "C.java", SRC_DIR + FS + "UsedInC.java"
     };
 
+    private static final String[] ARGS4 = new String[] {
+        "-d", BUG_ID + "-4", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
+    };
+
     /**
      * The entry point of the test.
      * @param args the array of command line arguments.
@@ -108,6 +119,7 @@
         }
         tester.printSummary();
         run(tester, ARGS3, TEST3, NO_TEST);
+        run(tester, ARGS4, TEST4, NO_TEST);
         tester.printSummary();
     }
 
--- a/test/tools/javac/6304921/TestLog.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/6304921/TestLog.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -33,9 +33,9 @@
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.parser.EndPosTable;
 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;
--- a/test/tools/javac/6402516/TestLocalElements.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/6402516/TestLocalElements.java	Thu Oct 25 23:25:08 2012 +0100
@@ -43,9 +43,9 @@
 
     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);
             }
 
--- a/test/tools/javac/6758789/T6758789a.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/6758789/T6758789a.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/6840059/T6840059.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/6840059/T6840059.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +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: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+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
--- a/test/tools/javac/7132880/T7132880.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/7132880/T7132880.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,4 +1,4 @@
-T7132880.java:23:12: compiler.err.cant.apply.symbol.1: 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: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.Double), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Double))),(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)))}
 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/DefiniteAssignment/T7181578.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 { }
+    }
+}
--- a/test/tools/javac/Diagnostics/6722234/T6722234a_1.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_1.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.inconvertible.types: 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
--- a/test/tools/javac/Diagnostics/6722234/T6722234a_2.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_2.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.inconvertible.types: 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
--- a/test/tools/javac/Diagnostics/6722234/T6722234b_1.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.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)
+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
--- a/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.inferred.do.not.conform.to.eq.bounds: compiler.misc.captured.type: 2, compiler.misc.captured.type: 2,compiler.misc.captured.type: 1)
+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
--- a/test/tools/javac/Diagnostics/6722234/T6722234c.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234c.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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, (compiler.misc.inconvertible.types: 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
--- a/test/tools/javac/Diagnostics/6862608/T6862608a.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/Diagnostics/6862608/T6862608a.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-T6862608a.java:19:33: compiler.err.cant.apply.symbol.1: 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>>))
+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
--- a/test/tools/javac/Diagnostics/6862608/T6862608b.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/Diagnostics/6862608/T6862608b.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.inconvertible.types: 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.typevar: compiler.misc.type.var: S, 1, java.lang.Object, kindname.method, <compiler.misc.type.var: S, 1,compiler.misc.type.var: T, 2>foo(compiler.misc.type.var: T, 2)),(compiler.misc.where.typevar: compiler.misc.type.var: S, 2, java.lang.Object, kindname.class, T66862608b)}
 1 error
--- a/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2009, 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/StringsInSwitch/7181320/BinOpInCaseLabel.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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     7181320
+ * @summary javac NullPointerException for switch labels with cast to String expressions
+ * @compile BinOpInCaseLabel.java
+ */
+
+public class BinOpInCaseLabel {
+    public static void main(String [] args) {
+        switch (args[0]) {
+            case "hello" + "world":
+                break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/StringsInSwitch/7181320/CastInCaseLabel.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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     7181320
+ * @summary javac NullPointerException for switch labels with cast to String expressions
+ * @compile CastInCaseLabel.java
+ */
+
+public class CastInCaseLabel {
+    public static void main(String [] args) {
+        switch (args[0]) {
+            case (String)"hello":
+                break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/StringsInSwitch/7181320/CondExprInCaseLabel.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @bug     7181320
+ * @summary javac NullPointerException for switch labels with cast to String expressions
+ * @compile CondExprInCaseLabel.java
+ */
+
+public class CondExprInCaseLabel {
+    public static void main(String [] args) {
+        final boolean cond = true;
+        switch (args[0]) {
+            case cond ? "hello" : "world":
+                break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/StringsInSwitch/7181320/CondExprInCaseLabel1.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @bug     7181320
+ * @summary javac NullPointerException for switch labels with cast to String expressions
+ * @compile CondExprInCaseLabel1.java
+ */
+
+public class CondExprInCaseLabel1 {
+    public static void main(String [] args) {
+        final boolean cond = true;
+        switch (args[0]) {
+            case cond ? (String)"hello" : "world":
+                break;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/StringsInSwitch/7181320/CondExprInCaseLabel2.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @bug     7181320
+ * @summary javac NullPointerException for switch labels with cast to String expressions
+ * @compile CondExprInCaseLabel2.java
+ */
+
+public class CondExprInCaseLabel2 {
+    public static void main(String [] args) {
+        final boolean cond = true;
+        switch (args[0]) {
+            case cond ? "hello" : (String)"world":
+                break;
+        }
+    }
+}
--- a/test/tools/javac/T6326754.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/T6326754.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.inconvertible.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: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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/TryWithResources/T7164542.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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) {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/TryWithResources/T7178324.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 7178324
+ * @summary Crash when compiling for(i : x) try(AutoCloseable x = ...) {}
+ * @compile T7178324.java
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+class T7178324 {
+    public static void main(String[] args) throws Exception {
+        List<File> files = new ArrayList<>();
+        for (File f : files)
+            try (FileInputStream is = new FileInputStream(f)) {
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/BasicRepeatingAnnotations.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @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.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foos {
+    Foo[] value();
+}
+
+@interface Bar {}
+
+@Foo @Foo
+@Foo
+@Bar
+@Foo
+@Foo
+@Foo
+@Foo
+@Foo @Foo
+@Foo
+class BasicRepeatingAnnos {}
+
+@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");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/CheckTargets.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @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.*;
+
+@ContainedBy(Foos.class)
+@Target(ElementType.TYPE)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@Target(ElementType.ANNOTATION_TYPE)
+@interface Foos {
+    Foo[] value();
+}
+
+@ContainedBy(Bars.class)
+@Target(ElementType.TYPE)
+@interface Bar {}
+
+@ContainerFor(Bar.class)
+@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE })
+@interface Bars {
+    Bar[] value();
+}
+
+
+@ContainedBy(Bazs.class)
+@Target({ ElementType.TYPE, ElementType.ANNOTATION_TYPE })
+@interface Baz {}
+
+@ContainerFor(Baz.class)
+@Target({ ElementType.ANNOTATION_TYPE, ElementType.TYPE })
+@interface Bazs {
+    Baz[] value();
+}
+
+
+public class CheckTargets {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/ContainerHasRepeatedContained.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Bar BarContainer ContainerHasRepeatedContained
+ * @run compile ContainerHasRepeatedContained.java
+ */
+
+import java.lang.annotation.ContainedBy;
+import java.lang.annotation.ContainerFor;
+
+@ContainedBy(BarContainer.class)
+@interface Bar {}
+
+@Bar
+@Bar
+@ContainerFor(Bar.class)
+@interface BarContainer {
+    Bar[] value();
+}
+
+public class ContainerHasRepeatedContained {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/DelayRepeatedContainer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @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"; }
+}
+
+@Bar("katt")
+@Bar("lol")
+@ContainedBy(BarContainer.class)
+@interface Bar {
+    String value();
+}
+
+@ContainerFor(Bar.class)
+@interface BarContainer {
+    Bar[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/InvalidTarget.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean Foos Foo
+ * @run compile/fail InvalidTarget.java
+ */
+
+import java.lang.annotation.*;
+
+@ContainedBy(Foos.class)
+@Target(ElementType.ANNOTATION_TYPE)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@Target(ElementType.TYPE)
+@interface Foos {
+    Foo[] value();
+}
+
+public class InvalidTargets {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingContainedBy.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 Smoke test for repeating annotations
+ * @compile/fail MissingContainedBy.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+
+@ContainerFor(MissingContainedBy.class)
+@interface Foos {
+    MissingContainedBy[] value();
+}
+
+public @interface MissingContainedBy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/MissingContainerFor.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @summary Smoke test for repeating annotations
+ * @compile/fail MissingContainerFor.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@interface Foos {
+    MissingContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface MissingContainerFor {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/NestedContainers.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @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.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(FoosFoos.class)
+@ContainerFor(Foo.class)
+@interface Foos {
+    Foo[] value();
+}
+
+@ContainerFor(Foos.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface FoosFoos {
+    Foos[] value();
+}
+
+@Foo
+@Foo
+class BasicRepeatingAnnos {}
+
+@Foos({})
+@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");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepMemberAnno.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact 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.ContainedBy;
+import java.lang.annotation.ContainerFor;
+
+public class RepMemberAnno {
+    @Bar("Apa") @Bar("Banan")
+    public void meh() {}
+}
+
+@ContainedBy(BarContainer.class)
+@interface Bar {
+    String value();
+}
+
+@ContainerFor(Bar.class)
+@interface BarContainer {
+    Bar[] value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepSelfMemberAnno.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean RepSelfMemberAnno BarContainer BarContainerContainer
+ * @run compile RepSelfMemberAnno.java
+ */
+
+import java.lang.annotation.*;
+
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(BarContainer.class)
+public @interface RepSelfMemberAnno {
+    @RepSelfMemberAnno @RepSelfMemberAnno
+    String meh() default "banan";
+}
+
+
+@ContainedBy(BarContainerContainer.class)
+@Retention(RetentionPolicy.RUNTIME)
+@ContainerFor(RepSelfMemberAnno.class)
+@interface BarContainer {
+    RepSelfMemberAnno[] value();
+}
+
+@ContainerFor(BarContainer.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface BarContainerContainer {
+    BarContainer[] value();
+    String meh() default "apa";
+}
+
+@BarContainer(value={})
+@BarContainer(value={})
+@interface Bar {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/RepeatingAndContainerPresent.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @summary Smoke test for repeating annotations
+ * @compile/fail RepeatingAndContainerPresent.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@interface Foos {
+    Foo[] value();
+}
+
+
+@Foo
+@Foo
+@Foos({})
+public class RepeatingAndContainerPresent {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/SelfRepeatingAnnotations.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @summary Smoke test for repeating annotations
+ * @bug 7151010
+ *
+ * @run clean SelfRepeatingAnnotations Foos SelfRepeatingAnno
+ * @run compile SelfRepeatingAnnotations.java
+ * @run main SelfRepeatingAnnotations
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(SelfRepeatingAnno.class)
+@Retention(RetentionPolicy.RUNTIME)
+@interface Foos {
+    SelfRepeatingAnno[] value();
+}
+
+@SelfRepeatingAnno
+@Retention(RetentionPolicy.RUNTIME)
+@SelfRepeatingAnno
+@ContainedBy(Foos.class)
+@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");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/SingleRepeatingAndContainer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 Smoke test for repeating annotations
+ * @compile SingleRepeatingAndContainer.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainedBy(Foos.class)
+@interface Foo {}
+
+@ContainerFor(Foo.class)
+@interface Foos {
+    Foo[] value();
+}
+
+@Foo
+@Foos({})
+public class SingleRepeatingAndContainer {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/UseWrongContainedBy.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 Smoke test for repeating annotations
+ * @compile/fail UseWrongContainedBy.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(UseWrongContainedBy.class)
+@interface Foos {
+    UseWrongContainedBy[] value();
+}
+
+@ContainedBy(Target.class)
+public @interface UseWrongContainedBy {}
+
+@UseWrongContainedBy @UseWrongContainedBy
+@interface Foo {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/UseWrongContainerFor.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 Smoke test for repeating annotations
+ * @compile/fail UseWrongContainerFor.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(Retention.class)
+@interface Foos {
+    UseWrongContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface UseWrongContainerFor {}
+
+@UseWrongContainerFor @UseWrongContainerFor
+@interface Foo {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/WrongContainedBy.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 Smoke test for repeating annotations
+ * @compile/fail WrongContainedBy.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(WrongContainedBy.class)
+@interface Foos {
+    WrongContainedBy[] value();
+}
+
+@ContainedBy(Target.class)
+public @interface WrongContainedBy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/repeatingAnnotations/WrongContainerFor.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 Smoke test for repeating annotations
+ * @compile/fail WrongContainerFor.java
+ * @bug 7151010
+ */
+
+import java.lang.annotation.*;
+
+@ContainerFor(Retention.class)
+@interface Foos {
+    WrongContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface WrongContainerFor {}
--- a/test/tools/javac/api/7086261/T7086261.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/api/7086261/T7086261.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/EndPositions.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,98 @@
+/*
+ * 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 7196760
+ * @summary javac doesn't report Diagnostic end positions properly when
+ * an annotation processor is present
+ */
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.Trees;
+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;
+
+@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("Compilation succeeded unexpectedly");
+
+        List<Diagnostic<? extends JavaFileObject>> errors = diagnostics.getDiagnostics();
+        if (errors.size() != 1)
+            throw new AssertionError("Expected one error only, but found " + errors.size() + " 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() +"]");
+
+        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();
+    }
+}
--- a/test/tools/javac/api/T6397104.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/api/T6397104.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/classfiles/ClassVersionChecker.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @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 =
+                {{51, -1, -1, -1, -1, -1, -1, -1},
+                 {48, 46, 47, 48, 49, 50, 51, 51},
+                 {48, 46, 47, 48, 49, 50, 51, 51},
+                 {48, -1, -1, 48, 49, 50, 51, 51},
+                 {51, -1, -1, -1, 49, 50, 51, 51},
+                 {51, -1, -1, -1, -1, 50, 51, 51},
+                 {51, -1, -1, -1, -1, -1, 51, 51},
+                 {51, -1, -1, -1, -1, -1, -1, 51}};
+
+        // 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++;
+    }
+}
--- a/test/tools/javac/defender/DeprecatedDefenderSyntax.java	Fri Oct 19 17:48:08 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +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.
- */
-
-/*
- * @test
- * @summary check that compiler issue warning if obsolete syntax for extension methods is used
- * @author  Maurizio Cimadamore
- * @compile/fail/ref=DeprecatedDefenderSyntax.out -Werror -XDrawDiagnostics DeprecatedDefenderSyntax.java
- */
-
-interface DeprecatedDefenderSyntax {
-    void m() default Impl.m;
-    
-    class Impl {
-        static void m(Object o) { }
-    }
-}
--- a/test/tools/javac/defender/DeprecatedDefenderSyntax.out	Fri Oct 19 17:48:08 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-DeprecatedDefenderSyntax.java:32:10: compiler.warn.obsolete.defender.syntax
-- compiler.err.warnings.and.werror
-1 error
-1 warning
--- a/test/tools/javac/defender/Neg12.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/defender/Neg12.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,4 +1,4 @@
 Neg12.java:44:12: compiler.err.does.not.override.abstract: Neg12.D, m(java.lang.String), Neg12.I2
-Neg12.java:47:10: compiler.err.cant.apply.symbols: kindname.method, m, ,{(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:48:10: compiler.err.cant.apply.symbol.1: kindname.method, m, java.lang.Integer, compiler.misc.no.args, kindname.class, Neg12.B, (compiler.misc.arg.length.mismatch)
+Neg12.java:47:10: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.no.args,{(compiler.misc.inapplicable.method: kindname.method, Neg12.B, m(java.lang.Integer), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, Neg12.I1, m(java.lang.String), (compiler.misc.arg.length.mismatch))}
+Neg12.java:48: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
--- a/test/tools/javac/diags/CheckExamples.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/CheckExamples.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/diags/MessageInfo.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/MessageInfo.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/diags/RunExamples.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/RunExamples.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/diags/examples.not-yet.txt	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples.not-yet.txt	Thu Oct 25 23:25:08 2012 +0100
@@ -1,10 +1,12 @@
 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.cant.apply.symbol
 compiler.err.cant.read.file                             # (apt.JavaCompiler?)
 compiler.err.cant.select.static.class.from.param.type
 compiler.err.illegal.char.for.encoding
+compiler.err.invalid.containedby.annotation             # should not happen
+compiler.err.invalid.containedby.annotation.invalid.value # "can't" happen
+compiler.err.invalid.containedby.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
@@ -103,43 +105,8 @@
 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.err.break.inside.lambda                                                 #LAMBDA
-compiler.err.cant.ref.non.effectively.final.var                                  #LAMBDA
-compiler.err.cont.inside.lambda                                                  #LAMBDA
 compiler.err.default.overrides.object.member                                     #LAMBDA
 compiler.err.defender.in.class                                                   #LAMBDA
 compiler.err.defender.methods.not.supported.in.source                            #LAMBDA
-compiler.err.incompatible.thrown.types.in.lambda                                 #LAMBDA
-compiler.err.invalid.reference                                                   #LAMBDA
-compiler.err.must.be.throwable                                                   #LAMBDA
 compiler.err.types.incompatible.unrelated.defaults                               #LAMBDA
-compiler.err.unexpected.lambda                                                   #LAMBDA
-compiler.err.unexpected.meth.reference                                           #LAMBDA
-compiler.misc.cant.access.inner.cls.constr                                       #LAMBDA
-compiler.misc.cant.apply.symbol                                                  #LAMBDA
-compiler.misc.cant.apply.symbol.1                                                #LAMBDA
-compiler.misc.cant.apply.symbols                                                 #LAMBDA
-compiler.misc.cant.resolve.location.args                                         #LAMBDA
-compiler.misc.cant.resolve.location.args.params                                  #LAMBDA
-compiler.misc.cyclic.lambda.inference                                            #LAMBDA
 compiler.misc.conditional.target.cant.be.void                                    #LAMBDA
-compiler.misc.incompatible.targets.for.lambda.conv                               #LAMBDA
-compiler.misc.incompatible.type.in.conditional                                   #LAMBDA
-compiler.misc.inner.cls                                                          #LAMBDA
-compiler.misc.invalid.generic.target.for.lambda.conv                             #LAMBDA
-compiler.misc.lambda                                                             #LAMBDA
-compiler.misc.no.suitable.sam.inst                                               #LAMBDA
-compiler.misc.no.target.method.for.lambda.conv                                   #LAMBDA
-compiler.misc.ref.ambiguous                                                      #LAMBDA
-compiler.misc.target.for.lambda.conv.must.be.interface                           #LAMBDA
-compiler.misc.type.lambda                                                        #LAMBDA
-compiler.misc.type.mref                                                          #LAMBDA
-compiler.misc.type.conditional                                                   #LAMBDA
-compiler.misc.bad.enclosing.method                                               #LAMBDA
-compiler.misc.infer.incompatible.ret.types.in.lambda                             #LAMBDA
-compiler.misc.infer.incompatible.arg.types.in.lambda                             #LAMBDA
-compiler.misc.invalid.reference                                                  #LAMBDA
-compiler.misc.non-static.cant.be.ref                                             #LAMBDA
-compiler.misc.not.def.access.class.intf.cant.access                              #LAMBDA
-compiler.note.potential.lambda.found                                             #LAMBDA
-compiler.warn.obsolete.defender.syntax                                           #LAMBDA
--- a/test/tools/javac/diags/examples/ApplicableMethodFound1.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/ApplicableMethodFound1.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CantAccessInnerClsConstr.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.cant.access.inner.cls.constr
+// key: compiler.misc.invalid.mref
+// options: -XDallowMethodReferences
+
+class CantAccessInnerClsConstructor {
+
+    interface SAM {
+        Outer m();
+    }
+
+    class Outer { }
+
+    static void test() {
+        SAM s = Outer::new;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CantApplySymbolFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.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
+// options: -XDallowMethodReferences
+
+class CantApplySymbolFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    static void f(String s) { }
+
+    void test() {
+        SAM s = CantApplySymbolFragment::f;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CantApplySymbolsFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.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
+// options: -XDallowMethodReferences
+
+class CantApplySymbolsFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    static void f() { }
+
+    static void f(String s) { }
+
+    void test() {
+        SAM s = CantApplySymbolsFragment::f;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CantRefNonEffectivelyFinalVar.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.cant.ref.non.effectively.final.var
+// key: compiler.misc.inner.cls
+// key: compiler.misc.lambda
+// options: -XDallowLambda -XDallowEffectivelyFinalInInnerClasses
+
+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++;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CantResolveLocationArgsFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.cant.resolve.location.args
+// key: compiler.misc.location
+// key: compiler.err.invalid.mref
+// options: -XDallowMethodReferences
+
+class CantResolveLocationArgsFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    void test() {
+        SAM s = CantResolveLocationArgsFragment::f;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CantResolveLocationArgsParamsFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.cant.resolve.location.args.params
+// key: compiler.misc.location
+// key: compiler.err.invalid.mref
+// options: -XDallowMethodReferences
+
+class CantResolveLocationArgsParamsFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    void test() {
+        SAM s = CantResolveLocationArgsParamsFragment::<String>f;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ContainedByDocumentedMismatch.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.not.documented
+
+import java.lang.annotation.*;
+
+@Documented
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+class ContainedByDocumentedMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ContainedByInheritedMismatch.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.not.inherited
+
+import java.lang.annotation.*;
+
+@Inherited
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+class ContainedByInheritedMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ContainedByNoValue.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.no.value
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos {}
+
+@Anno
+@Anno
+class ContainedByNoValue { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ContainedByNonDefault.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.elem.nondefault
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); String foo(); }
+
+@Anno
+@Anno
+class ContainedByNonDefault { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ContainedByRetentionMismatch.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.retention
+
+import java.lang.annotation.*;
+
+@Retention(RetentionPolicy.RUNTIME)
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+class ContainedByRetentionMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ContainedByTargetMismatch.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.incompatible.target
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@Target(ElementType.METHOD)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+class ContainedByTargetMismatch { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ContainedByWrongValueType.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.value.return
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { String value(); }
+
+@Anno
+@Anno
+class ContainedByWrongValueType { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CyclicInference.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.err.cant.apply.symbol
+// key: compiler.misc.cyclic.inference
+// options: -XDallowLambda -XDallowPoly
+
+class CyclicInference {
+    interface SAM<X> {
+        void m(X x);
+    }
+
+    <Z> void g(SAM<Z> sz) { }
+
+    void test() {
+        g(x-> {});
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/DefaultAllowedInIntfAnnotationMember.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,28 @@
+/*
+ * 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.default.allowed.in.intf.annotation.member
+
+interface DefaultAllowedInIntfAnnotationMember {
+    String value() default "";
+}
--- a/test/tools/javac/diags/examples/DuplicateAnnotation.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/DuplicateAnnotation.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 { }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/DuplicateAnnotationJava8.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+
+@interface Anno { }
+
+@Anno
+@Anno
+class DuplicateAnnotationJava8 { }
--- a/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ForeachBadInitialization.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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) {}
+    }
+}
--- a/test/tools/javac/diags/examples/IllegalDot.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/IllegalDot.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IllegalStartOfStmt.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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) }
+    }
+}
--- a/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/InaccessibleVarargsType/InaccessibleVarargsType.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleAbstracts.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.not.a.functional.intf.1
+// key: compiler.misc.incompatible.abstracts
+// options: -XDallowLambda
+
+class IncompatibleAbstracts {
+
+    interface SAM {
+        void m(String s);
+        void m(Integer i);
+    }
+
+    SAM s = x-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleArgTypesInLambda.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.arg.types.in.lambda
+// options: -XDallowLambda -XDallowPoly
+
+class IncompatibleArgTypesInLambda {
+    interface SAM {
+        void m(Integer x);
+    }
+
+    SAM s = (String x)-> {};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleDescsInFunctionalIntf.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.
+ */
+
+// 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
+// options: -XDallowLambda
+
+class IncompatibleDescsInFunctionalIntf {
+    interface A {
+        Integer m(String i) throws Exception;
+    }
+
+    interface B {
+        String m(String i);
+    }
+
+    interface SAM extends A,B { }
+
+    SAM s = x-> { };
+}
--- a/test/tools/javac/diags/examples/IncompatibleEqUpperBounds.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/IncompatibleEqUpperBounds.java	Thu Oct 25 23:25:08 2012 +0100
@@ -21,7 +21,7 @@
  * questions.
  */
 
-//key: compiler.err.cant.apply.symbol.1
+//key: compiler.err.cant.apply.symbol
 //key: compiler.misc.incompatible.eq.upper.bounds
 
 import java.util.List;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleRetTypeInLambda.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.prob.found.req
+// key: compiler.misc.inconvertible.types
+// key: compiler.misc.incompatible.ret.type.in.lambda
+// options: -XDallowLambda -XDallowPoly
+
+class IncompatibleRetTypeInLambda {
+    interface SAM {
+        Integer m();
+    }
+
+    SAM s = ()-> "";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleRetTypeInMref.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.inconvertible.types
+// key: compiler.misc.incompatible.ret.type.in.mref
+// options: -XDallowMethodReferences -XDallowPoly
+
+class IncompatibleRetTypeInMref {
+    interface SAM {
+        Integer m();
+    }
+
+    static String f() { }
+
+    SAM s = IncompatibleRetTypeInMref::f;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleThrownTypesInLambda.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.incompatible.thrown.types.in.lambda
+// options: -XDallowLambda
+
+class IncompatibleThrownTypesInLambda {
+    interface SAM {
+        void m();
+    }
+
+    SAM s = ()-> { throw new Exception(); };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleThrownTypesInMref.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.incompatible.thrown.types.in.mref
+// options: -XDallowMethodReferences
+
+class IncompatibleThrownTypesInMref {
+    interface SAM {
+        void m();
+    }
+
+    static void f() throws Exception { }
+
+    SAM s = IncompatibleThrownTypesInMref::f;
+}
--- a/test/tools/javac/diags/examples/IncompatibleTypes1.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,8 @@
  * questions.
  */
 
+// key: compiler.misc.infer.no.conforming.instance.exists
 // key: compiler.err.prob.found.req
-// key: compiler.misc.infer.no.conforming.instance.exists
 
 class IncompatibleTypes1<V> {
     <T> IncompatibleTypes1<Integer> m() {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/IncompatibleTypesInConditional.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.prob.found.req
+// key: compiler.misc.incompatible.type.in.conditional
+// key: compiler.misc.inconvertible.types
+// options: -XDallowPoly
+
+class IncompatibleTypesInConditional {
+
+    interface A { }
+    interface B { }
+
+    B b = true ? (A)null : (B)null;
+}
--- a/test/tools/javac/diags/examples/InconvertibleTypes.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/InconvertibleTypes.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/diags/examples/InferArgsLengthMismatch.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/InferArgsLengthMismatch.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 {
--- a/test/tools/javac/diags/examples/InferNoConformingAssignment.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/InferNoConformingAssignment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.inconvertible.types
 // key: compiler.misc.infer.no.conforming.assignment.exists
 
--- a/test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/InferVarargsArgumentMismatch.java	Thu Oct 25 23:25:08 2012 +0100
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.infer.varargs.argument.mismatch
 // key: compiler.misc.inconvertible.types
 
--- a/test/tools/javac/diags/examples/InferredDoNotConformToEq.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/InferredDoNotConformToEq.java	Thu Oct 25 23:25:08 2012 +0100
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.inferred.do.not.conform.to.eq.bounds
 
 import java.util.*;
--- a/test/tools/javac/diags/examples/InferredDoNotConformToUpper.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/InferredDoNotConformToUpper.java	Thu Oct 25 23:25:08 2012 +0100
@@ -21,7 +21,7 @@
  * questions.
  */
 
-// key: compiler.err.cant.apply.symbol.1
+// key: compiler.err.cant.apply.symbol
 // key: compiler.misc.inferred.do.not.conform.to.upper.bounds
 
 import java.util.*;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/InvalidGenericDescInFunctionalInterface.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.prob.found.req
+// key: compiler.misc.invalid.generic.desc.in.functional.intf
+// options: -XDallowLambda
+
+class InvalidGenericDescInFunctionalIntf {
+
+    interface SAM {
+        <Z> void m();
+    }
+
+    SAM s = x-> { };
+}
--- a/test/tools/javac/diags/examples/KindnameConstructor.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/KindnameConstructor.java	Thu Oct 25 23:25:08 2012 +0100
@@ -23,7 +23,7 @@
 
 // key: compiler.misc.kindname.constructor
 // key: compiler.misc.kindname.class
-// 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
 // key: compiler.misc.count.error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/MissingReturnValueFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.missing.ret.val
+// options: -XDallowLambda
+
+class MissingReturnValueFragment {
+    interface SAM {
+        String m();
+    }
+
+    void test() {
+        SAM s = ()->{};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NoAbstracts.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.1
+// key: compiler.misc.no.abstracts
+// options: -XDallowLambda
+
+class NoAbstracts {
+
+    interface SAM { }
+
+    SAM s = x-> { };
+}
--- a/test/tools/javac/diags/examples/NoArgs.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/NoArgs.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NoSuitableFunctionalIntfInst.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.prob.found.req
+// key: compiler.misc.no.suitable.functional.intf.inst
+// options: -XDallowLambda
+
+class NoSuitableFunctionalIntfInst {
+
+    interface SAM<X extends Number> {
+        void m(X x);
+    }
+
+    SAM<?> ss = (String s)-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NoUniqueMaximalInstance.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.no.unique.maximal.instance.exists
+
+class NoUniqueMaximalInstance {
+    <Z extends Integer> Z m() { return null; }
+
+    { String s = m(); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NonStaticCantBeRefFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.non-static.cant.be.ref
+// key: compiler.misc.invalid.mref
+// options: -XDallowMethodReferences
+
+class NonStaticCantBeRefFragment {
+
+    interface SAM {
+        void m(Integer u);
+    }
+
+    void f(Integer i) { }
+
+    static void test() {
+        SAM s = NonStaticCantBeRefFragment::f;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NotAFunctionalIntf.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.prob.found.req
+// key: compiler.misc.not.a.functional.intf
+// options: -XDallowLambda
+
+class NotAFunctionalIntf {
+
+    abstract class SAM {
+        abstract <Z> void m();
+    }
+
+    SAM s = x-> { };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NotAllowedClass.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 {}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NotAllowedVariable.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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;
+    }
+}
--- a/test/tools/javac/diags/examples/NotApplicableMethodFound.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/NotApplicableMethodFound.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -23,7 +23,7 @@
 
 // key: compiler.misc.not.applicable.method.found
 // key: compiler.note.verbose.resolve.multi.1
-// 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: -XDverboseResolution=inapplicable,failure
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NotDefAccessClassIntfCantAccessFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.
+ */
+
+// key: compiler.err.prob.found.req
+// key: compiler.misc.not.def.access.class.intf.cant.access
+// key: compiler.misc.invalid.mref
+// options: -XDallowMethodReferences
+
+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;
+    }
+}
--- a/test/tools/javac/diags/examples/PossibleLossPrecision.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/PossibleLossPrecision.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/PotentialLambdaFound.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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: -XDallowLambda -XDidentifyLambdaCandidate=true
+
+class PotentialLambdaFound {
+
+    interface SAM {
+        void m();
+    }
+
+    SAM s = new SAM() { public void m() { } };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/RefAmbiguousFragment.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.ref.ambiguous
+// key: compiler.misc.invalid.mref
+// options: -XDallowMethodReferences
+
+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;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/RepeatingAnnotationAndContainer.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.containedby.annotation.repeated.and.container.present
+
+import java.lang.annotation.*;
+
+@ContainedBy(Annos.class)
+@interface Anno { }
+
+@ContainerFor(Anno.class)
+@interface Annos { Anno[] value(); }
+
+@Anno
+@Anno
+@Annos(@Anno)
+class RepeatingAnnotationAndContainer { }
--- a/test/tools/javac/diags/examples/ResourceNotApplicableToType.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/ResourceNotApplicableToType.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/diags/examples/UndeterminedType1.java	Fri Oct 19 17:48:08 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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.prob.found.req
-// 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();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/UnexpectedLambda.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.unexpected.lambda
+// options: -XDallowLambda
+
+class UnexpectedLambda {
+    { (()-> { })++; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/UnexpectedMref.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.unexpected.mref
+// options: -XDallowMethodReferences
+
+class UnexpectedLambda {
+    { (Foo::bar)++; }
+}
--- a/test/tools/javac/diags/examples/VarargsArgumentMismatch.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/VarargsArgumentMismatch.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,7 +21,7 @@
  * 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
 
--- a/test/tools/javac/diags/examples/VerboseResolveMulti1.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/VerboseResolveMulti1.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -23,7 +23,7 @@
 
 // key: compiler.misc.not.applicable.method.found
 // key: compiler.note.verbose.resolve.multi.1
-// 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: -XDverboseResolution=inapplicable,failure
--- a/test/tools/javac/diags/examples/WhereCaptured.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/WhereCaptured.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 @@
 // 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.err.cant.apply.symbol
 // key: compiler.misc.inferred.do.not.conform.to.eq.bounds
 // key: compiler.misc.captured.type
 // options: -XDdiags=where,simpleNames
--- a/test/tools/javac/diags/examples/WhereCaptured1.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/WhereCaptured1.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 @@
 // 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.err.cant.apply.symbol
 // key: compiler.misc.inferred.do.not.conform.to.eq.bounds
 // key: compiler.misc.captured.type
 // key: compiler.misc.type.null
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/WhereFreshTvar.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.where.fresh.typevar
+// key: compiler.misc.where.description.typevar
+// key: compiler.err.prob.found.req
+// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
+// options: -XDdiags=where,simpleNames
+// run: simple
+
+import java.util.*;
+
+class WhereFreshTvar {
+    <T extends List<T>> T m() {}
+
+    { List<String> ls = m(); }
+}
--- a/test/tools/javac/diags/examples/WhereIntersection.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/WhereIntersection.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/diags/examples/WhereTypeVar.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/diags/examples/WhereTypeVar.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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,7 +24,7 @@
 // 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/WrongContainedBy.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.container.no.containerfor
+// key: compiler.err.invalid.container.wrong.containedby
+
+import java.lang.annotation.*;
+
+@ContainerFor(WrongContainedBy.class)
+@interface Foos {
+    WrongContainedBy[] value();
+}
+
+@ContainedBy(Target.class)
+public @interface WrongContainedBy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/WrongContainerFor.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.invalid.container.wrong.containerfor
+// key: compiler.err.invalid.container.no.containedby
+
+import java.lang.annotation.*;
+
+@ContainerFor(Retention.class)
+@interface Foos {
+    WrongContainerFor[] value();
+}
+
+@ContainedBy(Foos.class)
+public @interface WrongContainerFor {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/enum/7160084/T7160084a.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/enum/7160084/T7160084b.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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);
+    }
+}
--- a/test/tools/javac/failover/CheckAttributedTree.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/failover/CheckAttributedTree.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -68,7 +68,7 @@
 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.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.tree.JCTree.JCImport;
--- a/test/tools/javac/generics/7034511/T7034511a.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/7034511/T7034511a.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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: java.lang.String[], compiler.misc.type.captureof: 1, ?[])
 1 error
--- a/test/tools/javac/generics/7034511/T7034511b.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/7034511/T7034511b.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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: java.lang.Object[], compiler.misc.type.captureof: 1, ?[])
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/diamond/7188968/T7188968.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/diamond/7188968/T7188968.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/generics/inference/6611449/T6611449.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/inference/6611449/T6611449.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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: T)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.upper.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.upper.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch: T))}
-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.upper.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.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
--- a/test/tools/javac/generics/inference/6638712/T6638712a.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712a.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-T6638712a.java:16:33: compiler.err.cant.apply.symbol.1: 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>>))
+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
--- a/test/tools/javac/generics/inference/6638712/T6638712c.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712c.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.infer.no.conforming.assignment.exists: T, (compiler.misc.inconvertible.types: 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
--- a/test/tools/javac/generics/inference/6638712/T6638712d.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712d.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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.inferred.do.not.conform.to.lower.bounds: java.lang.String, java.lang.Integer)
+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.inferred.do.not.conform.to.lower.bounds: java.lang.String, java.lang.Integer)
 1 error
--- a/test/tools/javac/generics/inference/6838943/T6838943.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/inference/6838943/T6838943.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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, (compiler.misc.inconvertible.types: 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
--- a/test/tools/javac/generics/inference/7086586/T7086586.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/inference/7086586/T7086586.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
-T7086586.java:14:20: compiler.err.cant.apply.symbol.1: 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.1: 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.1: 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.1: 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: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
--- a/test/tools/javac/generics/inference/7086601/T7086601a.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/inference/7086601/T7086601a.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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,java.lang.Object))}
 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.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object))}
-T7086601a.java:28:9: compiler.err.cant.apply.symbol.1: kindname.method, m3, java.lang.Iterable<? super S>[], java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>, kindname.class, T7086601, (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object)
-T7086601a.java:32:9: compiler.err.cant.apply.symbol.1: kindname.method, m3, java.lang.Iterable<? super S>[], java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>, kindname.class, T7086601, (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object)
+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,java.lang.Object))}
+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.Integer,java.lang.String,java.lang.Object))}
 4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7154127/T7154127.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,21 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7154127
+ * @summary Inference cleanup: remove bound check analysis from visitors in Types.java
+ * @compile/fail/ref=T7154127.out -XDrawDiagnostics 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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7154127/T7154127.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,2 @@
+T7154127.java:19:49: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B<U>)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306a.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306a.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,6 @@
+T7177306a.java:13:34: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.List, java.util.List<E>
+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:33: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7177306a, T7177306a<java.lang.Object>
+- compiler.err.warnings.and.werror
+1 error
+3 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306b.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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>
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306b.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306c.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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!");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306d.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306e.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,17 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug 7177306
+ * @summary Regression: unchecked method call does not erase return type
+ * @compile/fail/ref=T7177306e.out -XDrawDiagnostics 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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/7177306/T7177306e.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,2 @@
+T7177306e.java:15: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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test1.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test2.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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>());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test3.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test3.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test4.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test4.out	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/generics/typevars/T7148242.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/generics/typevars/T7148242.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/lambda/BadBreakContinue.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadBreakContinue.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,13 +1,13 @@
-BadBreakContinue.java:37:21: compiler.err.break.inside.lambda
-BadBreakContinue.java:38:21: compiler.err.cont.inside.lambda
-BadBreakContinue.java:40:27: compiler.err.break.inside.lambda
-BadBreakContinue.java:41:27: compiler.err.cont.inside.lambda
-BadBreakContinue.java:46:29: compiler.err.break.inside.lambda
-BadBreakContinue.java:47:29: compiler.err.cont.inside.lambda
-BadBreakContinue.java:49:35: compiler.err.break.inside.lambda
-BadBreakContinue.java:50:35: compiler.err.cont.inside.lambda
-BadBreakContinue.java:57:29: compiler.err.break.inside.lambda
-BadBreakContinue.java:58:29: compiler.err.cont.inside.lambda
-BadBreakContinue.java:60:35: compiler.err.break.inside.lambda
-BadBreakContinue.java:61:35: compiler.err.cont.inside.lambda
+BadBreakContinue.java:37:21: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:38:21: compiler.err.cont.outside.loop
+BadBreakContinue.java:40:27: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:41:27: compiler.err.cont.outside.loop
+BadBreakContinue.java:46:29: compiler.err.undef.label: loop
+BadBreakContinue.java:47:29: compiler.err.undef.label: loop
+BadBreakContinue.java:49:35: compiler.err.undef.label: loop
+BadBreakContinue.java:50:35: compiler.err.undef.label: loop
+BadBreakContinue.java:57:29: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:58:29: compiler.err.cont.outside.loop
+BadBreakContinue.java:60:35: compiler.err.break.outside.switch.loop
+BadBreakContinue.java:61:35: compiler.err.cont.outside.loop
 12 errors
--- a/test/tools/javac/lambda/BadConv03.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadConv03.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-BadConv03.java:40:11: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, BadConv03.B)
+BadConv03.java:40:11: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, BadConv03.B))
 1 error
--- a/test/tools/javac/lambda/BadConv04.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadConv04.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
 BadConv04.java:40:5: compiler.err.types.incompatible.diff.ret: BadConv04.I2, BadConv04.I1, m()
-BadConv04.java:42:13: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, BadConv04.SAM)
+BadConv04.java:42: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
--- a/test/tools/javac/lambda/BadExpressionLambda.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadExpressionLambda.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-BadExpressionLambda.java:40:31: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.conditional.target.cant.be.void))
+BadExpressionLambda.java:40:31: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.conditional.target.cant.be.void))
 1 error
--- a/test/tools/javac/lambda/BadLambdaPos.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadLambdaPos.out	Thu Oct 25 23:25:08 2012 +0100
@@ -4,6 +4,6 @@
 BadLambdaPos.java:44:18: compiler.err.unexpected.lambda
 BadLambdaPos.java:44:34: compiler.err.unexpected.lambda
 BadLambdaPos.java:45:21: compiler.err.unexpected.lambda
-BadLambdaPos.java:49:22: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-BadLambdaPos.java:50:28: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
+BadLambdaPos.java:49:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadLambdaPos.java:50:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
 8 errors
--- a/test/tools/javac/lambda/BadMethodCall.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadMethodCall.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-BadMethodCall.java:36:50: compiler.err.cant.apply.symbol.1: 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>))
+BadMethodCall.java:36: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
--- a/test/tools/javac/lambda/BadRecovery.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadRecovery.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,2 @@
-BadRecovery.java:38:9: compiler.err.cant.apply.symbol.1: kindname.method, m, BadRecovery.SAM1, compiler.misc.type.lambda, kindname.class, BadRecovery, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.arg.types.in.lambda))
-BadRecovery.java:38:77: compiler.err.cant.resolve.location: kindname.variable, f, , , (compiler.misc.location: kindname.class, BadRecovery, null)
-2 errors
+BadRecovery.java:38:9: compiler.err.cant.apply.symbol: kindname.method, m, BadRecovery.SAM1, @1363, kindname.class, BadRecovery, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))
+1 error
--- a/test/tools/javac/lambda/BadReturn.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadReturn.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-BadReturn.java:42:42: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
-BadReturn.java:47:49: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+BadReturn.java:42:42: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
+BadReturn.java:47:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Comparable<?>))
 2 errors
--- a/test/tools/javac/lambda/BadTargetType.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/BadTargetType.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
-BadTargetType.java:37:24: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-BadTargetType.java:38:17: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-BadTargetType.java:41:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, java.lang.Object, compiler.misc.type.lambda, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.target.for.lambda.conv.must.be.interface))
-BadTargetType.java:42:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, java.lang.Object, compiler.misc.type.lambda, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.target.for.lambda.conv.must.be.interface))
+BadTargetType.java:37:24: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadTargetType.java:38:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+BadTargetType.java:41:9: compiler.err.cant.apply.symbol: kindname.method, m1, java.lang.Object, @1454, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
+BadTargetType.java:42:9: compiler.err.cant.apply.symbol: kindname.method, m2, java.lang.Object, @1483, kindname.class, BadTargetType, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
 4 errors
--- a/test/tools/javac/lambda/EffectivelyFinalTest.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/EffectivelyFinalTest.java	Thu Oct 25 23:25:08 2012 +0100
@@ -23,59 +23,54 @@
 
 /*
  * @test
- * @summary integrate effectively final analysis with DA/DU
- * @compile/fail/ref=EffectivelyFinalTest.out -XDrawDiagnostics EffectivelyFinalTest.java
+ * @summary Integrate efectively 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 {
 
-    interface SAM {
-        int m();
-    }
-
-    void foo(SAM s) { }
-
     void m1(int x) {
         int y = 1;
-        foo(() -> x+y); // Legal: x and y are both effectively final.
+        new Object() { { System.out.println(x+y); } }; //ok - both x and y are EF
     }
 
     void m2(int x) {
         int y;
         y = 1;
-        foo(() -> x+y); // Legal: x and y are both effectively final.
+        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;
-        foo(() -> x+y); // Illegal: y is effectively final, but not definitely assigned.
+        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;
-        foo(() -> x+y); // Legal: x and y are both effectively final.
+        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;
-        foo(() -> x+y); // Illegal: y is not effectively final.
+        new Object() { { System.out.println(x+y); } }; //error - y not EF
     }
 
     void m6(int x) {
-        foo(() -> x+1);
+        new Object() { { System.out.println(x+1); } }; //error - x not EF
         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)
+        new Object() { { System.out.println(x=1); } }; //error - x not EF
     }
 
     void m8() {
         int y;
-        foo(() -> y=1); // Illegal: y in the assignment does not denote a variable (see 6.5.6.1)
+        new Object() { { System.out.println(y=1); } }; //error - y not EF
     }
 }
--- a/test/tools/javac/lambda/EffectivelyFinalTest.out	Fri Oct 19 17:48:08 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-EffectivelyFinalTest.java:51:21: compiler.err.var.might.not.have.been.initialized: y
-EffectivelyFinalTest.java:65:21: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
-EffectivelyFinalTest.java:69:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
-EffectivelyFinalTest.java:74:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
-EffectivelyFinalTest.java:79:19: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
-5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/EffectivelyFinalTest01.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,6 @@
+EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:60:47: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:64:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:69:45: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.inner.cls)
+EffectivelyFinalTest.java:74:45: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.inner.cls)
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/EffectivelyFinalTest02.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,14 @@
+EffectivelyFinalTest.java:46:47: compiler.err.var.might.not.have.been.initialized: y
+EffectivelyFinalTest.java:34:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:34:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:40:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:40:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:46:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:53:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:53:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:60:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:60:47: compiler.err.local.var.accessed.from.icls.needs.final: y
+EffectivelyFinalTest.java:64:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:69:45: compiler.err.local.var.accessed.from.icls.needs.final: x
+EffectivelyFinalTest.java:74:45: compiler.err.local.var.accessed.from.icls.needs.final: y
+13 errors
--- a/test/tools/javac/lambda/ErroneousArg.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/ErroneousArg.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 ErroneousArg.java:50:11: compiler.err.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, TestErroneousArg, null)
-ErroneousArg.java:51:11: compiler.err.cant.apply.symbol.1: 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:51: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:52:11: compiler.err.cant.apply.symbols: kindname.method, g, int,{(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))),(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)))}
 ErroneousArg.java:53:11: compiler.err.ref.ambiguous: g, kindname.method, g(java.lang.String), ErroneousArg, kindname.method, g(java.lang.Double), ErroneousArg
 ErroneousArg.java:54:11: compiler.err.non-static.cant.be.ref: kindname.method, h()
--- a/test/tools/javac/lambda/LambdaConv09.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/LambdaConv09.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
-LambdaConv09.java:63:19: compiler.err.prob.found.req: (compiler.misc.no.target.method.for.lambda.conv: kindname.interface, LambdaConv09.Foo1)
-LambdaConv09.java:64:19: compiler.err.prob.found.req: (compiler.misc.no.target.method.for.lambda.conv: kindname.interface, LambdaConv09.Foo2)
-LambdaConv09.java:65:19: compiler.err.prob.found.req: (compiler.misc.no.target.method.for.lambda.conv: kindname.interface, LambdaConv09.Foo3)
-LambdaConv09.java:67:19: compiler.err.prob.found.req: (compiler.misc.no.target.method.for.lambda.conv: kindname.interface, LambdaConv09.Foo5)
+LambdaConv09.java:63:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo1))
+LambdaConv09.java:64:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo2))
+LambdaConv09.java:65:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo3))
+LambdaConv09.java:67:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, LambdaConv09.Foo5))
 4 errors
--- a/test/tools/javac/lambda/LambdaConv10.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/LambdaConv10.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-LambdaConv10.java:36:39: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.arg.types.in.lambda)
+LambdaConv10.java:36:39: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
 1 error
--- a/test/tools/javac/lambda/LambdaConv21.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/LambdaConv21.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,6 +1,6 @@
-LambdaConv21.java:46:43: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Void))
-LambdaConv21.java:47:43: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Void, void))
-LambdaConv21.java:53:33: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
-LambdaConv21.java:54:53: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.unexpected.ret.val))
-LambdaConv21.java:57:33: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+LambdaConv21.java:46:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Void))
+LambdaConv21.java:47:43: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Void, void))
+LambdaConv21.java:53:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
+LambdaConv21.java:54:53: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))
+LambdaConv21.java:57:33: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.Void))
 5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/LambdaEffectivelyFinalTest.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
+ * @summary 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)
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/LambdaEffectivelyFinalTest.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,6 @@
+LambdaEffectivelyFinalTest.java:51:21: compiler.err.var.might.not.have.been.initialized: y
+LambdaEffectivelyFinalTest.java:65:21: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:69:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:74:19: compiler.err.cant.ref.non.effectively.final.var: x, (compiler.misc.lambda)
+LambdaEffectivelyFinalTest.java:79:19: compiler.err.cant.ref.non.effectively.final.var: y, (compiler.misc.lambda)
+5 errors
--- a/test/tools/javac/lambda/LambdaExpr10.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/LambdaExpr10.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,9 +1,9 @@
-LambdaExpr10.java:39:28: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-LambdaExpr10.java:40:32: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-LambdaExpr10.java:44:40: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-LambdaExpr10.java:45:46: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-LambdaExpr10.java:49:29: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-LambdaExpr10.java:50:33: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-LambdaExpr10.java:54:35: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
-LambdaExpr10.java:55:49: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+LambdaExpr10.java:39:28: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:40:32: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:44:40: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:45:46: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:49:29: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:50:33: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+LambdaExpr10.java:54:35: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
+LambdaExpr10.java:55:49: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, void))
 8 errors
--- a/test/tools/javac/lambda/LambdaExpr19.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/LambdaExpr19.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,6 +1,6 @@
-LambdaExpr19.java:38:9: compiler.err.cant.apply.symbol.1: kindname.method, m, LambdaExpr19.SAM, compiler.misc.type.lambda, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
-LambdaExpr19.java:45:9: compiler.err.cant.apply.symbol.1: kindname.method, m, LambdaExpr19.SAM, compiler.misc.type.lambda, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
-LambdaExpr19.java:52:9: compiler.err.cant.apply.symbol.1: kindname.method, m, LambdaExpr19.SAM, compiler.misc.type.lambda, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
-LambdaExpr19.java:60:9: compiler.err.cant.apply.symbol.1: kindname.method, m, LambdaExpr19.SAM, compiler.misc.type.lambda, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
-LambdaExpr19.java:68:9: compiler.err.cant.apply.symbol.1: kindname.method, m, LambdaExpr19.SAM, compiler.misc.type.lambda, kindname.class, LambdaExpr19, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String)))
+LambdaExpr19.java:38:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @1369, 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:45:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @1522, 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:52:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @1690, 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:60:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @1843, 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:68:9: compiler.err.cant.apply.symbol: kindname.method, m, LambdaExpr19.SAM, @1985, 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
--- a/test/tools/javac/lambda/LambdaExprNotVoid.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/LambdaExprNotVoid.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-LambdaExprNotVoid.java:35:21: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, void))
-LambdaExprNotVoid.java:36:21: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, void))
+LambdaExprNotVoid.java:35:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
+LambdaExprNotVoid.java:36:21: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, void))
 2 errors
--- a/test/tools/javac/lambda/MethodReference04.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference04.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-MethodReference04.java:34:16: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
+MethodReference04.java:34:16: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
 1 error
--- a/test/tools/javac/lambda/MethodReference09.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference09.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,4 +1,4 @@
 MethodReference09.java:42:23: compiler.err.non-static.cant.be.ref: kindname.method, getThis()
-MethodReference09.java:42:20: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, getX, compiler.misc.no.args, MethodReference09.Foo, kindname.class, MethodReference09.Foo<X>, (compiler.misc.arg.length.mismatch)))
+MethodReference09.java:42: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:43:20: compiler.err.non-static.cant.be.ref: kindname.variable, this
 3 errors
--- a/test/tools/javac/lambda/MethodReference20.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference20.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-MethodReference20.java:42:26: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.constructor, (compiler.misc.cant.apply.symbol.1: 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:43:9: compiler.err.cant.apply.symbol.1: kindname.method, test, MethodReference20.SAM<java.lang.Integer>, compiler.misc.type.mref, kindname.class, MethodReference20<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.constructor, (compiler.misc.cant.apply.symbol.1: 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:42: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:43:9: compiler.err.cant.apply.symbol: kindname.method, test, MethodReference20.SAM<java.lang.Integer>, @1543, 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.inconvertible.types: java.lang.Integer, java.lang.String)))))
 2 errors
--- a/test/tools/javac/lambda/MethodReference22.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference22.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,11 +1,11 @@
-MethodReference22.java:61:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)))
-MethodReference22.java:62:9: compiler.err.cant.apply.symbol.1: kindname.method, call1, MethodReference22.SAM1, compiler.misc.type.mref, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))))
-MethodReference22.java:67:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))
-MethodReference22.java:68:9: compiler.err.cant.apply.symbol.1: kindname.method, call1, MethodReference22.SAM1, compiler.misc.type.mref, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))
-MethodReference22.java:76:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String)))
-MethodReference22.java:77:9: compiler.err.cant.apply.symbol.1: kindname.method, call2, MethodReference22.SAM2, compiler.misc.type.mref, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String))))
-MethodReference22.java:78:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))
-MethodReference22.java:79:9: compiler.err.cant.apply.symbol.1: kindname.method, call2, MethodReference22.SAM2, compiler.misc.type.mref, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)))
+MethodReference22.java:61:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)))
+MethodReference22.java:62:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @1993, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String))))
+MethodReference22.java:67:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))
+MethodReference22.java:68:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @2264, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String))))
+MethodReference22.java:76:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String)))
+MethodReference22.java:77:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @2568, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String))))
+MethodReference22.java:78: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:79:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @2661, 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:84:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22
-MethodReference22.java:86:9: compiler.err.cant.apply.symbols: kindname.method, call3, compiler.misc.type.mref,{(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)))),(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))))}
+MethodReference22.java:86:9: compiler.err.cant.apply.symbols: kindname.method, call3, @2875,{(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM2), (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)))),(compiler.misc.inapplicable.method: kindname.method, MethodReference22, call3(MethodReference22.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)))))}
 10 errors
--- a/test/tools/javac/lambda/MethodReference23.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference23.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,4 +1,6 @@
-MethodReference23.java:78:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))
-MethodReference23.java:79:9: compiler.err.cant.apply.symbol.1: kindname.method, call12, MethodReference23.SAM12, compiler.misc.type.mref, kindname.class, MethodReference23, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.reference: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23)))
+MethodReference23.java:73:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, MethodReference23, MethodReference23))
+MethodReference23.java:74:9: compiler.err.cant.apply.symbol: kindname.method, call11, MethodReference23.SAM11, @2134, 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:78:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.constructor, (compiler.misc.cant.access.inner.cls.constr: Inner1, , MethodReference23))
+MethodReference23.java:79:9: compiler.err.cant.apply.symbol: kindname.method, call12, MethodReference23.SAM12, @2276, 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:93:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference23.SAM21), MethodReference23, kindname.method, call3(MethodReference23.SAM22), MethodReference23
-3 errors
+5 errors
--- a/test/tools/javac/lambda/MethodReference28.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference28.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,14 +1,14 @@
-MethodReference28.java:52:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, static_m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
-MethodReference28.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:54:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:58:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer)))
-MethodReference28.java:59:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
-MethodReference28.java:60:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:61:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:66:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
-MethodReference28.java:67:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:68:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:73:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:74:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, m3, java.lang.String, MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
-MethodReference28.java:75:19: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, m4, java.lang.String[], MethodReference28,int, kindname.class, MethodReference28, (compiler.misc.varargs.argument.mismatch: (compiler.misc.inconvertible.types: MethodReference28, 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, static_m2, java.lang.Integer,java.lang.Integer, int, kindname.class, MethodReference28, (compiler.misc.arg.length.mismatch)))
+MethodReference28.java:53: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:54: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:58:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.Integer)))
+MethodReference28.java:59: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:60: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:61: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:66: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:67: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:68: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:73: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:74: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:75: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
--- a/test/tools/javac/lambda/MethodReference33.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference33.java	Thu Oct 25 23:25:08 2012 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @summary bounds vs. unbound constructor references
+ * @summary test bridged constructor references
  */
 
 public class MethodReference33 {
@@ -45,18 +45,10 @@
         X m(int i);
     }
     
-    interface BridgeSAMUnbound<X> {
-        X m(MethodReference33 rec, int i);
-    }
-    
     interface NonBridgeSAMBound<X> {
         X m();
     }
     
-    interface NonBridgeSAMUnbound<X> {
-        X m(MethodReference33 rec);
-    }
-    
     void test() {
         BridgeSAMBound<Foo> b1 = Foo::new;
         b1.m(1);
@@ -66,11 +58,7 @@
 
     public static void main(String[] args) {
         MethodReference33 test = new MethodReference33();
-        BridgeSAMUnbound<Foo> b1 = Foo::new;
-        b1.m(test, 1);
-        NonBridgeSAMUnbound<Foo> b2 = Foo::new;
-        b2.m(test);
         test.test();
-        assertTrue(assertionCount == 4);
+        assertTrue(assertionCount == 2);
     }
 }
--- a/test/tools/javac/lambda/MethodReference37.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference37.java	Thu Oct 25 23:25:08 2012 +0100
@@ -25,7 +25,7 @@
  * @test
  * @summary spurious exceptions when checking references to inner constructors where
  *          the enclosing class is not defined in any outer context
- * @compile MethodReference37.java
+ * @compile/fail/ref=MethodReference37.out -XDrawDiagnostics MethodReference37.java
  */
 
 class MethodReference37 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/MethodReference37.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,5 @@
+MethodReference37.java:45: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:50: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:55: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:59: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
--- a/test/tools/javac/lambda/MethodReference39.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference39.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-MethodReference39.java:43:23: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.constructor, (compiler.misc.cant.apply.symbol.1: kindname.constructor, Inner, java.lang.String, MethodReference39.Sup,java.lang.String, kindname.class, MethodReference39.Sub.Inner, (compiler.misc.arg.length.mismatch)))
+MethodReference39.java:43: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
--- a/test/tools/javac/lambda/MethodReference40.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference40.java	Thu Oct 25 23:25:08 2012 +0100
@@ -23,8 +23,8 @@
 
 /*
  * @test
- * @summary check that parameter type that is subtype of enclosing class is accepted
- * @compile -XDrawDiagnostics MethodReference40.java
+ * @summary check that unbound constructor reference are not accepted
+ * @compile/fail/ref=MethodReference40.out -XDrawDiagnostics MethodReference40.java
  */
 class MethodReference40 {
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/MethodReference40.out	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,2 @@
+MethodReference40.java:42: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
--- a/test/tools/javac/lambda/MethodReference51.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference51.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,7 +1,7 @@
-MethodReference51.java:60:21: compiler.err.invalid.reference: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , int, (compiler.misc.location: kindname.class, MethodReference51, null))
-MethodReference51.java:61:21: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:62:21: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, g, int,{(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Number,java.lang.Integer), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Integer,java.lang.Number), (compiler.misc.arg.length.mismatch))}))
-MethodReference51.java:63:32: compiler.err.prob.found.req: (compiler.misc.invalid.reference: 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:64:21: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int)))
-MethodReference51.java:65:21: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.not.def.access.class.intf.cant.access: j(int), MethodReference51.Foo))
+MethodReference51.java:60: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:61: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:62: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.Number,java.lang.Integer), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference51, g(java.lang.Integer,java.lang.Number), (compiler.misc.arg.length.mismatch))}))
+MethodReference51.java:63: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:64:21: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, h(int)))
+MethodReference51.java:65: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
--- a/test/tools/javac/lambda/MethodReference52.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference52.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-MethodReference52.java:56:25: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int[], long[]))
-MethodReference52.java:58:28: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Class<? extends java.util.List>, java.lang.Class<java.util.List<java.lang.String>>))
+MethodReference52.java:56:25: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int[], long[]))
+MethodReference52.java:58: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
--- a/test/tools/javac/lambda/MethodReference53.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReference53.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-MethodReference53.java:43:11: compiler.err.invalid.reference: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, unknown, , , (compiler.misc.location: kindname.class, MethodReference53, null))
+MethodReference53.java:43: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
--- a/test/tools/javac/lambda/MethodReferenceParserTest.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/MethodReferenceParserTest.java	Thu Oct 25 23:25:08 2012 +0100
@@ -108,7 +108,7 @@
         SUPER("super"),
         NEW("new Foo()"),
         METHOD("m()"),
-        FIELD("a.f"),        
+        FIELD("a.f"),
         UBOUND_SIMPLE("A"),
         UNBOUND_ARRAY1("int[]"),
         UNBOUND_ARRAY2("A<G>[][]"),
@@ -127,22 +127,23 @@
     }
 
     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");
-        
+        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);
+            return expressionTemplate
+                    .replaceAll("#R", rk.getReferenceString(qk, gk))
+                    .replaceAll("#S", sk.subExpression);
         }
     }
 
@@ -230,7 +231,7 @@
         try {
             ct.parse();
         } catch (Throwable ex) {
-            throw new AssertionError("Error thron when parsing the following source:\n" + source.getCharContent(true));
+            throw new AssertionError("Error thrown when parsing the following source:\n" + source.getCharContent(true));
         }
         check();
     }
--- a/test/tools/javac/lambda/TargetType04.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType04.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-TargetType04.java:37:43: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Double, java.lang.Integer))
-TargetType04.java:38:43: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Integer, java.lang.Double))
+TargetType04.java:37: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:38: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
--- a/test/tools/javac/lambda/TargetType06.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType06.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-TargetType06.java:46:23: compiler.err.cant.apply.symbol.1: kindname.method, map, TargetType06.Function<B,B>, compiler.misc.type.lambda, kindname.class, TargetType06, (compiler.misc.cyclic.lambda.inference)
+TargetType06.java:46:23: compiler.err.cant.apply.symbol: kindname.method, map, TargetType06.Function<B,B>, @1504, kindname.class, TargetType06, (compiler.misc.cyclic.inference: B)
 1 error
--- a/test/tools/javac/lambda/TargetType10.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType10.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-TargetType10.java:39:11: compiler.err.cant.apply.symbol.1: kindname.method, compose, TargetType10.Function<B,C>,TargetType10.Function<A,? extends B>, compiler.misc.type.lambda,compiler.misc.type.lambda, kindname.class, TargetType10.Test, (compiler.misc.cyclic.lambda.inference)
+TargetType10.java:39:11: compiler.err.cant.apply.symbol: kindname.method, compose, TargetType10.Function<B,C>,TargetType10.Function<A,? extends B>, @1563,@1578, kindname.class, TargetType10.Test, (compiler.misc.cyclic.inference: B,A)
 1 error
--- a/test/tools/javac/lambda/TargetType11.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType11.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,4 +1,4 @@
 TargetType11.java:37:61: compiler.warn.unchecked.varargs.non.reifiable.type: TargetType11.Predicate<? super T>
-TargetType11.java:41:32: compiler.err.cant.apply.symbol.1: kindname.method, and, TargetType11.Predicate<? super T>[], compiler.misc.type.lambda,compiler.misc.type.lambda, kindname.class, TargetType11.Test, (compiler.misc.cyclic.lambda.inference)
+TargetType11.java:41:32: compiler.err.cant.apply.symbol: kindname.method, and, TargetType11.Predicate<? super T>[], @1708,@1720, kindname.class, TargetType11.Test, (compiler.misc.cyclic.inference: T)
 1 error
 1 warning
--- a/test/tools/javac/lambda/TargetType17.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType17.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,9 +1,9 @@
-TargetType17.java:35:21: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-TargetType17.java:36:23: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-TargetType17.java:37:19: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-TargetType17.java:38:21: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-TargetType17.java:39:23: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-TargetType17.java:40:25: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-TargetType17.java:41:21: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
-TargetType17.java:42:27: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
+TargetType17.java:35:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:36:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:37:19: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:38:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:39:23: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:40:25: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:41:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
+TargetType17.java:42:27: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
 8 errors
--- a/test/tools/javac/lambda/TargetType20.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType20.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-TargetType20.java:41:10: compiler.err.cant.apply.symbol.1: kindname.method, call, TargetType20.SAM2<Z>,TargetType20.SAM2<Z>, TargetType20.SAM2<java.lang.String>,TargetType20.SAM2<java.lang.String>, kindname.class, TargetType20.Test, (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
+TargetType20.java:41:10: compiler.err.cant.apply.symbol: kindname.method, call, TargetType20.SAM2<Z>,TargetType20.SAM2<Z>, @1491,@1522, kindname.class, TargetType20.Test, (compiler.misc.inferred.do.not.conform.to.eq.bounds: java.lang.String, java.lang.String,java.lang.Object)
 1 error
--- a/test/tools/javac/lambda/TargetType21.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType21.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
 TargetType21.java:49:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, call(TargetType21.SAM2), TargetType21
-TargetType21.java:51:9: compiler.err.cant.apply.symbols: kindname.method, call, compiler.misc.type.lambda,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.lambda.inference)),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String))))}
+TargetType21.java:51:9: compiler.err.cant.apply.symbols: kindname.method, call, @1749,{(compiler.misc.inapplicable.method: kindname.method, TargetType21, <R,A>call(TargetType21.SAM3<R,A>), (compiler.misc.cyclic.inference: A)),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM2), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val)))),(compiler.misc.inapplicable.method: kindname.method, TargetType21, call(TargetType21.SAM1), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String))))}
 2 errors
--- a/test/tools/javac/lambda/TargetType24.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType24.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
 TargetType24.java:55:37: compiler.err.prob.found.req: (compiler.misc.inconvertible.types: java.lang.String, boolean)
-TargetType24.java:56:45: compiler.err.cant.apply.symbol.1: kindname.method, forAll2, TargetType24.FSub<java.lang.Character,java.lang.String>, compiler.misc.type.lambda, kindname.class, TargetType24.Array<A>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String)))
-TargetType24.java:57:101: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Boolean))
-TargetType24.java:58:104: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))
+TargetType24.java:56:45: compiler.err.cant.apply.symbol: kindname.method, forAll2, TargetType24.FSub<java.lang.Character,java.lang.String>, @1932, 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:57: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:58:104: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: boolean, java.lang.String))
 4 errors
--- a/test/tools/javac/lambda/TargetType26.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType26.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-TargetType26.java:37:7: compiler.err.cant.apply.symbol.1: kindname.method, call, Z, compiler.misc.type.lambda, kindname.class, TargetType26, (compiler.misc.cyclic.lambda.inference)
+TargetType26.java:37:7: compiler.err.cant.apply.symbol: kindname.method, call, Z, @1334, kindname.class, TargetType26, (compiler.misc.cyclic.inference: Z)
 1 error
--- a/test/tools/javac/lambda/TargetType27.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType27.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-TargetType27.java:39:9: compiler.err.cant.apply.symbol.1: kindname.method, m, TargetType27.F<A,R>, compiler.misc.type.lambda, kindname.class, TargetType27, (compiler.misc.cyclic.lambda.inference)
+TargetType27.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType27.F<A,R>, @1484, kindname.class, TargetType27, (compiler.misc.cyclic.inference: R)
 1 error
--- a/test/tools/javac/lambda/TargetType33.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType33.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
-TargetType33.java:42:31: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
-TargetType33.java:42:46: compiler.err.prob.found.req: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch))))
-TargetType33.java:43:9: compiler.err.cant.apply.symbol.1: kindname.method, m, TargetType33.A<java.lang.Integer>, compiler.misc.type.conditional, kindname.class, TargetType33, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
-TargetType33.java:44:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, TargetType33.A<Z>, compiler.misc.type.conditional, kindname.class, TargetType33, (compiler.misc.infer.no.conforming.assignment.exists: Z, (compiler.misc.incompatible.type.in.conditional: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, intRes, java.lang.Object, compiler.misc.no.args, kindname.class, TargetType33, (compiler.misc.arg.length.mismatch)))))
+TargetType33.java:42: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:42: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:43:9: compiler.err.cant.apply.symbol: kindname.method, m, TargetType33.A<java.lang.Integer>, @1511, 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:44:9: compiler.err.cant.apply.symbol: kindname.method, m2, TargetType33.A<Z>, @1559, 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
--- a/test/tools/javac/lambda/TargetType36.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType36.java	Thu Oct 25 23:25:08 2012 +0100
@@ -23,10 +23,11 @@
 
 /*
  * @test
+ * @ignore
  * @summary check that target type of cast is propagated to conditional subexpressions
  * @compile TargetType36.java
  */
-class TargetType36 {
+class TargetType36 { //awaits spec wording on cast vs. poly
     
     interface SAM {
        int m(int i, int j);
--- a/test/tools/javac/lambda/TargetType38.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType38.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-TargetType38.java:40:30: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
-TargetType38.java:41:26: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+TargetType38.java:40:30: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
+TargetType38.java:41:26: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: java.lang.Object, TargetType38.I))
 2 errors
--- a/test/tools/javac/lambda/TargetType39.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType39.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-TargetType39.java:40:9: compiler.err.cant.apply.symbol.1: kindname.method, call, TargetType39.SAM<U,V>, compiler.misc.type.conditional, kindname.class, TargetType39, (compiler.misc.cyclic.lambda.inference)
-TargetType39.java:41:9: compiler.err.cant.apply.symbol.1: kindname.method, call, TargetType39.SAM<U,V>, compiler.misc.type.lambda, kindname.class, TargetType39, (compiler.misc.cyclic.lambda.inference)
+TargetType39.java:40:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM<U,V>, @1436, kindname.class, TargetType39, (compiler.misc.cyclic.inference: U)
+TargetType39.java:41:9: compiler.err.cant.apply.symbol: kindname.method, call, TargetType39.SAM<U,V>, @1473, kindname.class, TargetType39, (compiler.misc.cyclic.inference: V)
 2 errors
--- a/test/tools/javac/lambda/TargetType41.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType41.java	Thu Oct 25 23:25:08 2012 +0100
@@ -27,7 +27,7 @@
  * @compile/fail/ref=TargetType41.out -XDrawDiagnostics TargetType41.java
  */
 
-class TargetType40 {
+class TargetType41 {
     <X> void m(String s, java.util.List<String> lx) { }
 
     void test() {
--- a/test/tools/javac/lambda/TargetType41.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType41.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-TargetType41.java:34:9: compiler.err.cant.apply.symbol.1: kindname.method, m, java.lang.String,java.util.List<java.lang.String>, int,java.util.ArrayList<java.lang.Object>, kindname.class, TargetType40, (compiler.misc.infer.no.conforming.assignment.exists: X, (compiler.misc.inconvertible.types: int, java.lang.String))
+TargetType41.java:34: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
--- a/test/tools/javac/lambda/TargetType43.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType43.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
-TargetType43.java:34:20: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
+TargetType43.java:34:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
 TargetType43.java:34:30: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
-TargetType43.java:35:9: compiler.err.cant.apply.symbol.1: kindname.method, m, java.lang.Object, compiler.misc.type.lambda, kindname.class, TargetType43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.target.for.lambda.conv.must.be.interface))
+TargetType43.java:35:9: compiler.err.cant.apply.symbol: kindname.method, m, java.lang.Object, @1353, kindname.class, TargetType43, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf))
 TargetType43.java:35:21: compiler.err.cant.resolve.location: kindname.class, NonExistentClass, , , (compiler.misc.location: kindname.class, TargetType43, null)
 4 errors
--- a/test/tools/javac/lambda/TargetType44.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/TargetType44.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-TargetType44.java:43:9: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.type.lambda,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.arg.types.in.lambda)))}
-TargetType44.java:46:9: compiler.err.cant.apply.symbols: kindname.method, m, compiler.misc.type.lambda,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.incompatible.arg.types.in.lambda)))}
+TargetType44.java:43:9: compiler.err.cant.apply.symbols: kindname.method, m, @1460,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
+TargetType44.java:46:9: compiler.err.cant.apply.symbols: kindname.method, m, @1599,{(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Binary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda))),(compiler.misc.inapplicable.method: kindname.method, TargetType44, m(TargetType44.Unary), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.lambda)))}
 2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/TestInvokeDynamic.java	Thu Oct 25 23:25:08 2012 +0100
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 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
+ *
+ * @summary Add back-end support for invokedynamic
+ *
+ */
+
+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.Method;
+
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.api.JavacTool;
+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.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 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.JavaCompiler;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+import static com.sun.tools.javac.jvm.ClassFile.*;
+
+public class TestInvokeDynamic {
+
+    static int checkCount = 0;
+
+    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) {
+            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);
+                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 {
+        // Create a single file manager and compiler and reuse it for each compile to save time.
+        StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        for (StaticArgumentsArity arity : StaticArgumentsArity.values()) {
+            if (arity.arity == 0) {
+                new TestInvokeDynamic(arity).compileAndCheck(fm, tool);
+            } else {
+                for (StaticArgumentKind sak1 : StaticArgumentKind.values()) {
+                    if (arity.arity == 1) {
+                        new TestInvokeDynamic(arity, sak1).compileAndCheck(fm, tool);
+                    } else {
+                        for (StaticArgumentKind sak2 : StaticArgumentKind.values()) {
+                            if (arity.arity == 2) {
+                                new TestInvokeDynamic(arity, sak1, sak2).compileAndCheck(fm, tool);
+                            } else {
+                                for (StaticArgumentKind sak3 : StaticArgumentKind.values()) {
+                                    new TestInvokeDynamic(arity, sak1, sak2, sak3).compileAndCheck(fm, tool);
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        System.out.println("Total checks made: " + checkCount);
+    }
+
+    StaticArgumentsArity arity;
+    StaticArgumentKind[] saks;
+    JavaSource source;
+    DiagChecker dc;
+
+    TestInvokeDynamic(StaticArgumentsArity arity, StaticArgumentKind... saks) {
+        this.arity = arity;
+        this.saks = saks;
+        source = new JavaSource();
+        dc = new DiagChecker();
+    }
+
+    void compileAndCheck(JavaFileManager fm, JavaCompiler tool) throws Exception {
+        JavacTaskImpl ct = (JavacTaskImpl)tool.getTask(null, fm, dc,
+                null, null, Arrays.asList(source));
+        Context context = ct.getContext();
+        Symtab syms = Symtab.instance(context);
+        Names names = Names.instance(context);
+        ct.addTaskListener(new Indifier(syms, names));
+        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();
+    }
+
+    void verifyBytecode() {
+        File compiledTest = new File("Test.class");
+        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());
+            }
+        } 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 {\n" +
+                "   void m() { }\n" +
+                "   void test() { m(); }\n" +
+                "}";
+
+        String source;
+
+        JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = source_template.replace("#SARGS", asSignatureString());
+        }
+
+        @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;
+
+        Indifier(Symtab syms, Names names) {
+            this.syms = syms;
+            this.names = names;
+        }
+
+        @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);
+                }
+                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();
+        }
+    }
+}
--- a/test/tools/javac/lambda/sqe/SAM_types/LambdaTest2_neg1.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/SAM_types/LambdaTest2_neg1.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-LambdaTest2_neg1.java:36:13: compiler.err.cant.apply.symbol.1: kindname.method, methodQooRoo, QooRoo<java.lang.Integer,java.lang.Integer,java.lang.Void>, compiler.misc.type.lambda, kindname.class, LambdaTest2_neg1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, QooRoo))
+LambdaTest2_neg1.java:36:13: compiler.err.cant.apply.symbol: kindname.method, methodQooRoo, QooRoo<java.lang.Integer,java.lang.Integer,java.lang.Void>, @1526, kindname.class, LambdaTest2_neg1, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, QooRoo)))
 1 error
--- a/test/tools/javac/lambda/sqe/SAM_types/NonSAM1.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/SAM_types/NonSAM1.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-NonSAM1.java:9:20: compiler.err.prob.found.req: (compiler.misc.no.target.method.for.lambda.conv: kindname.interface, Planet)
+NonSAM1.java:9:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.no.abstracts: kindname.interface, Planet))
 1 error
--- a/test/tools/javac/lambda/sqe/SAM_types/NonSAM3.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/SAM_types/NonSAM3.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,9 +1,9 @@
-NonSAM3.java:13:21: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, FooBar)
-NonSAM3.java:14:22: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, FooBar)
-NonSAM3.java:15:17: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, DE)
-NonSAM3.java:16:18: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, DE)
-NonSAM3.java:17:18: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, DE)
-NonSAM3.java:18:18: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, DE)
-NonSAM3.java:19:18: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, DE)
-NonSAM3.java:20:18: compiler.err.prob.found.req: (compiler.misc.incompatible.targets.for.lambda.conv: kindname.interface, DE)
+NonSAM3.java:13:21: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:14:22: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, FooBar))
+NonSAM3.java:15:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:16:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:17:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:18:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:19:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
+NonSAM3.java:20:18: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf.1: (compiler.misc.incompatible.abstracts: kindname.interface, DE))
 8 errors
--- a/test/tools/javac/lambda/sqe/lambdaExpression/AbstractClass_neg.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/lambdaExpression/AbstractClass_neg.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-AbstractClass_neg.java:14:17: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
+AbstractClass_neg.java:14:17: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
 1 error
--- a/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression3.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression3.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-InvalidExpression3.java:12:71: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, int))
+InvalidExpression3.java:12:71: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.String, int))
 1 error
--- a/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression4.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression4.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-InvalidExpression4.java:14:17: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.arg.types.in.lambda)
+InvalidExpression4.java:14:17: compiler.err.prob.found.req: (compiler.misc.incompatible.arg.types.in.lambda)
 1 error
--- a/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression5.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression5.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-InvalidExpression5.java:10:20: compiler.err.prob.found.req: (compiler.misc.target.for.lambda.conv.must.be.interface)
+InvalidExpression5.java:10:20: compiler.err.prob.found.req: (compiler.misc.not.a.functional.intf)
 1 error
--- a/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression6.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/lambdaExpression/InvalidExpression6.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,3 +1,3 @@
-InvalidExpression6.java:14:30: compiler.err.break.inside.lambda
-InvalidExpression6.java:15:26: compiler.err.cont.inside.lambda
+InvalidExpression6.java:14:30: compiler.err.break.outside.switch.loop
+InvalidExpression6.java:15:26: compiler.err.cont.outside.loop
 2 errors
--- a/test/tools/javac/lambda/sqe/methodReference/MethodRef_neg.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/methodReference/MethodRef_neg.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,5 +1,5 @@
-MethodRef_neg.java:28:15: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: 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:30:15: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.String))
-MethodRef_neg.java:31:13: compiler.err.prob.found.req: (compiler.misc.invalid.reference: kindname.method, (compiler.misc.cant.apply.symbol.1: kindname.method, make, compiler.misc.no.args, java.lang.Integer, kindname.class, MethodRef_neg, (compiler.misc.arg.length.mismatch)))
-MethodRef_neg.java:32:13: compiler.err.prob.found.req: (compiler.misc.infer.incompatible.ret.types.in.lambda: (compiler.misc.inconvertible.types: void, java.lang.Integer))
+MethodRef_neg.java:28: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:30:15: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: int, java.lang.String))
+MethodRef_neg.java:31: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:32:13: compiler.err.prob.found.req: (compiler.misc.incompatible.ret.type.in.mref: (compiler.misc.inconvertible.types: void, java.lang.Integer))
 4 errors
--- a/test/tools/javac/lambda/sqe/typeInference/InferenceTest_neg5.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/lambda/sqe/typeInference/InferenceTest_neg5.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,2 +1,2 @@
-InferenceTest_neg5.java:12:13: compiler.err.cant.apply.symbol.1: kindname.method, method1, InferenceTest_neg5.SAM1<X>, compiler.misc.type.lambda, kindname.class, InferenceTest_neg5, (compiler.misc.cyclic.lambda.inference)
+InferenceTest_neg5.java:12:13: compiler.err.cant.apply.symbol: kindname.method, method1, InferenceTest_neg5.SAM1<X>, @387, kindname.class, InferenceTest_neg5, (compiler.misc.cyclic.inference: X)
 1 error
--- a/test/tools/javac/newlines/Newlines.sh	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/newlines/Newlines.sh	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/parser/JavacParserTest.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/parser/JavacParserTest.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7073631
+ * @bug 7073631 7159445 7156633
  * @summary tests error and diagnostics positions
  * @author  Jan Lahoda
  */
@@ -49,11 +49,17 @@
 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;
@@ -63,13 +69,15 @@
 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 final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+
+    private JavacParserTest(){}
+
+    public static void main(String... args) throws Exception {
+        new JavacParserTest().run(args);
     }
 
-    static class MyFileObject extends SimpleJavaFileObject {
+    class MyFileObject extends SimpleJavaFileObject {
 
         private String text;
 
@@ -86,11 +94,11 @@
     /*
      * converts Windows to Unix style LFs for comparing strings
      */
-    private String normalize(String in) {
+    String normalize(String in) {
         return in.replace(System.getProperty("line.separator"), "\n");
     }
 
-    public CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
+    CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
 
         JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
                 null, Arrays.asList(new MyFileObject(code)));
@@ -98,7 +106,7 @@
         return cut;
     }
 
-    public List<String> getErroneousTreeValues(ErroneousTree node) {
+    List<String> getErroneousTreeValues(ErroneousTree node) {
 
         List<String> values = new ArrayList<>();
         if (node.getErrorTrees() != null) {
@@ -112,7 +120,8 @@
         return values;
     }
 
-    public void testPositionForSuperConstructorCalls() throws IOException {
+    @Test
+    void testPositionForSuperConstructorCalls() throws IOException {
         assert tool != null;
 
         String code = "package test; public class Test {public Test() {super();}}";
@@ -149,12 +158,12 @@
                 methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect()));
         assertEquals("testPositionForSuperConstructorCalls",
                 methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect()));
-
     }
 
-    public void testPositionForEnumModifiers() throws IOException {
-
-        String code = "package test; public enum Test {A;}";
+    @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)));
@@ -163,19 +172,21 @@
 
         ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
         ModifiersTree mt = clazz.getModifiers();
-
+        int spos = code.indexOf(theString);
+        int epos = spos + theString.length();
         assertEquals("testPositionForEnumModifiers",
-                38 - 24, pos.getStartPosition(cut, mt));
+                spos, pos.getStartPosition(cut, mt));
         assertEquals("testPositionForEnumModifiers",
-                44 - 24, pos.getEndPosition(cut, mt));
+                epos, pos.getEndPosition(cut, mt));
     }
 
-    public void testNewClassWithEnclosing() throws IOException {
+    @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 = Test.this.new d(); } }";
+                "Object o = " + theString + "; } }";
 
         JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
                 null, Arrays.asList(new MyFileObject(code)));
@@ -186,13 +197,16 @@
         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",
-                97 - 24, pos.getStartPosition(cut, est));
+                spos, pos.getStartPosition(cut, est));
         assertEquals("testNewClassWithEnclosing",
-                114 - 24, pos.getEndPosition(cut, est));
+                epos, pos.getEndPosition(cut, est));
     }
 
-    public void testPreferredPositionForBinaryOp() throws IOException {
+    @Test
+    void testPreferredPositionForBinaryOp() throws IOException {
 
         String code = "package test; public class Test {"
                 + "private void test() {"
@@ -211,7 +225,581 @@
                 condStartPos, condJC.pos);
     }
 
-    public void testPositionBrokenSource126732a() throws IOException {
+    @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@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)",
@@ -250,7 +838,7 @@
         }
     }
 
-    public void testPositionBrokenSource126732b() throws IOException {
+    void testPositionBrokenSource126732b() throws IOException {
         String[] commands = new String[]{
             "break",
             "break A",
@@ -291,246 +879,7 @@
         }
     }
 
-    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@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 {
+    void testStartPositionEnumConstantInit() throws IOException {
 
         String code = "package t; enum Test { AAA; }";
 
@@ -546,295 +895,34 @@
         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) { } } }";
-
-        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;
-                    System.out.println(node.getName() + "," + var.pos);
-                    assertEquals("testTryResourcePos", "in = null) { } } }",
-                            code.substring(var.pos));
+    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++;
                 }
-                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; } }";
-
-        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);
-    public 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);
-    public 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)
-    public 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);}
-    public 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)
-    public void testMethodError() throws IOException {
-
-        String code = "package Test; class ErrorTest {  "
-                + "static final void f) {String s = new String(); } }";
-        CompilationUnitTree 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);
-    }
-
-    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();
-        testMissingExponent();
-        testTryResourcePos();
-        testOperatorMissingError();
-        testMissingParenthesisError();
-        testMissingClassError();
-        testSwitchError();
-        testMethodError();
-    }
-
-    public static void main(String... args) throws IOException {
-        JavacParserTest jpt = new JavacParserTest("JavacParserTest");
-        jpt.testPositions();
-        System.out.println("PASS");
+        }
+        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 + " ??????????");
+        }
     }
 }
 
@@ -846,8 +934,10 @@
         }
     }
 
-    void assertFalse(String message, boolean empty) {
-        throw new UnsupportedOperationException("Not yet implemented");
+    void assertFalse(String message, boolean bvalue) {
+        if (bvalue == true) {
+            fail(message);
+        }
     }
 
     void assertEquals(String message, int i, long l) {
@@ -857,8 +947,6 @@
     }
 
     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);
         }
@@ -880,4 +968,11 @@
     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 {}
 }
--- a/test/tools/javac/parser/T4881269.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/parser/T4881269.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- a/test/tools/javac/processing/6348499/T6348499.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/processing/6348499/T6348499.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -47,6 +47,7 @@
     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 @@
             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();
--- a/test/tools/javac/processing/6414633/T6414633.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/processing/6414633/T6414633.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -43,20 +43,20 @@
     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 @@
             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) {
--- a/test/tools/javac/processing/T6920317.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/processing/T6920317.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -156,7 +156,9 @@
         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");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/T7196462.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 ../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;
+    }
+}
--- a/test/tools/javac/processing/TestWarnErrorCount.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/processing/TestWarnErrorCount.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/messager/MessagerDiags.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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.*;
+
+@SupportedSourceVersion(SourceVersion.RELEASE_6)
+@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;
+        }
+    }
+}
--- a/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/processing/options/testPrintProcessorInfo/TestWithXstdout.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -38,7 +38,8 @@
 public class TestWithXstdout {
     public static void main(String... args) throws Exception {
         File testSrc = new File(System.getProperty("test.src"));
-        File testClasses = new File(System.getProperty("test.classes"));
+        String testClasses = System.getProperty("test.classes", ".");
+        String testClassPath = System.getProperty("test.class.path", testClasses);
         File stdout = new File("stdout.out");
         run_javac("-XDrawDiagnostics",
                 "-XprintProcessorInfo",
@@ -46,7 +47,7 @@
                 "-proc:only",
                 "-processor",  "Test",
                 "-Xstdout", stdout.getPath(),
-                "-classpath", testClasses.getPath(),
+                "-classpath", testClassPath,
                 new File(testSrc, "Test.java").getPath());
         boolean ok = compare(stdout, new File(testSrc, "Test.out"));
         if (!ok)
--- a/test/tools/javac/quid/T6999438.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/quid/T6999438.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,4 +1,4 @@
-T6999438.java:8:8: compiler.err.expected: token.identifier
+T6999438.java:8:9: compiler.err.illegal.char: 35
 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: ';'
--- a/test/tools/javac/tree/DocCommentToplevelTest.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/tree/DocCommentToplevelTest.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -29,6 +29,7 @@
 
 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;
@@ -137,16 +138,16 @@
 
         new TreeScanner<ClassTree,Void>() {
 
-            Map<JCTree, String> docComments;
+            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.get(node) != null;
+                boolean foundComment = docComments.hasComment((JCTree) node);
                 if (expectedComment != foundComment) {
-                    error("Unexpected comment " + docComments.get(node) + " on toplevel");
+                    error("Unexpected comment " + docComments.getComment((JCTree) node) + " on toplevel");
                 }
                 return super.visitCompilationUnit(node, null);
             }
@@ -156,9 +157,9 @@
                 boolean expectedComment = tdk == ToplevelDocKind.HAS_DOC &&
                         pk == PackageKind.NO_PKG && ik == ImportKind.ZERO &&
                         node.getSimpleName().toString().equals("First");
-                boolean foundComment = docComments.get(node) != null;
+                boolean foundComment = docComments.hasComment((JCTree) node);
                 if (expectedComment != foundComment) {
-                    error("Unexpected comment " + docComments.get(node) + " on class " + node.getSimpleName());
+                    error("Unexpected comment " + docComments.getComment((JCTree) node) + " on class " + node.getSimpleName());
                 }
                 return super.visitClass(node, unused);
             }
--- a/test/tools/javac/tree/TreePosTest.java	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/tree/TreePosTest.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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
@@ -73,7 +73,7 @@
 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.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.tree.JCTree.JCNewClass;
--- a/test/tools/javac/varargs/6313164/T6313164.out	Fri Oct 19 17:48:08 2012 +0100
+++ b/test/tools/javac/varargs/6313164/T6313164.out	Thu Oct 25 23:25:08 2012 +0100
@@ -1,4 +1,4 @@
-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: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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/varargs/6313164/T7175433.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javadoc/T4696488.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javah/T7185778.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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 7185778
+ * @summary javah error "Not a valid class name" on class names with dollar signs
+ *   The first two tests are on an inner class name whose name does not contain $.
+ *   The second two tests are on an inner class name whose name does contain $.
+ *   The last test is on an outer class whose name contains $.
+ * @run main T7185778 T7185778$inner
+ * @run main T7185778 T7185778.inner
+ * @run main T7185778 T7185778$inner$
+ * @run main T7185778 T7185778.inner$
+ * @run main T7185778 xx$yy
+ */
+
+public class T7185778 {
+    class inner {
+        native byte[] xxxxx(String name);
+    }
+    class inner$ {
+        native byte[] xxxxx(String name);
+    }
+
+    static public void main(String[] args) {
+        int rc = com.sun.tools.javah.Main.run(args, null);
+        if ( rc != 0) {
+            throw new Error("javah returned non zero: " + rc);
+        }
+    }
+}
+
+class xx$yy {
+    native byte[] xxxxx(String name);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/T7186925.java	Thu Oct 25 23:25:08 2012 +0100
@@ -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;
+}