changeset 742:caadb412a4a6

merge with jdk7-b114
author mcimadamore
date Tue, 19 Oct 2010 16:26:29 +0100
parents 13e106a36674 01e8ac5fbefd
children f813d93e510c
files make/build.xml src/share/bin/launcher.sh-template src/share/classes/com/sun/source/tree/Tree.java src/share/classes/com/sun/source/util/TreeScanner.java src/share/classes/com/sun/tools/javac/code/Flags.java src/share/classes/com/sun/tools/javac/code/Scope.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/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/Check.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/Infer.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/ClassReader.java src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java src/share/classes/com/sun/tools/javac/jvm/Gen.java src/share/classes/com/sun/tools/javac/jvm/Target.java src/share/classes/com/sun/tools/javac/main/JavaCompiler.java src/share/classes/com/sun/tools/javac/model/JavacTypes.java src/share/classes/com/sun/tools/javac/parser/JavacParser.java src/share/classes/com/sun/tools/javac/parser/Scanner.java src/share/classes/com/sun/tools/javac/parser/ScannerFactory.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/TreeInfo.java src/share/classes/com/sun/tools/javac/util/Log.java src/share/classes/com/sun/tools/javac/util/Names.java test/tools/javac/T6341023.java test/tools/javac/diags/examples.not-yet.txt test/tools/javac/generics/typevars/5060485/Compatibility.out test/tools/javac/generics/typevars/5060485/Compatibility02.out test/tools/javac/lambda/BadTargetType.out test/tools/javac/lambda/LambdaConv02.out test/tools/javac/meth/MakeNegTests.sh test/tools/javac/processing/Xprint.java test/tools/javac/quid/MakeNegTests.sh test/tools/javac/tree/TreeScannerTest.java
diffstat 302 files changed, 9868 insertions(+), 2714 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Oct 18 17:21:50 2010 +0100
+++ b/.hgtags	Tue Oct 19 16:26:29 2010 +0100
@@ -79,3 +79,13 @@
 ff9c0a0bf7edf637a7dac5062b920924536ed79c jdk7-b102
 bd85271c580ce4600b1b2d5598daa19d02174cf7 jdk7-b103
 fc7219517ec16b28d729d259020a25b05ffdf0b6 jdk7-b104
+aaecac256d39c7cb536e70d20ddd833fc118e43a jdk7-b105
+112fcc00659dda1a356ec75d964584e4dae0228f jdk7-b106
+2c1c657f69a4ff608a43e1ac61baf3294cd55797 jdk7-b107
+a408ebb8b3d427dbb3d8ce153dfaeb060564a0a4 jdk7-b108
+4826378eaade4c6676c452efe954be4ee113cc11 jdk7-b109
+32da0f38d2fe96c558492b8707b40da24643d41e jdk7-b110
+8bec624274ef8535720cff553374347c2f4f5fb2 jdk7-b111
+fd2579b80b83bf5d4289426016c7d29174ba5dd9 jdk7-b112
+6dbd2d869b0573fa5b799a23cccff47d20c12696 jdk7-b113
+e4e7408cdc5b3d91d39161e1e94aad576ecc2dcd jdk7-b114
--- a/make/build.xml	Mon Oct 18 17:21:50 2010 +0100
+++ b/make/build.xml	Tue Oct 19 16:26:29 2010 +0100
@@ -275,6 +275,7 @@
             failOnError="false"
             errorProperty="findbugs.all.errors"
             warningsProperty="findbugs.all.warnings"
+            jvm="${target.java.home}/bin/java"
             jvmargs="-Xmx512M">
             <class location="${build.classes.dir}"/>
             <sourcePath>
@@ -626,7 +627,7 @@
         <genstubs
             srcdir="${import.jdk.src.dir}" destdir="${build.genstubs.dir}"
             includes="${import.jdk.stub.files}"
-            fork="true" classpath="${build.toolclasses.dir}:${build.bootstrap.dir}/classes:${ant.home}/lib/ant.jar"
+            fork="true" classpath="${build.toolclasses.dir}:${build.bootstrap.dir}/classes:${ant.core.lib}"
         />
     </target>
 
@@ -678,6 +679,7 @@
                     <filterset begintoken="#" endtoken="#">
                         <filter token="PROGRAM" value="@{name}"/>
                         <filter token="TARGET_JAVA" value="@{java}"/>
+                        <filter token="PS" value="${path.separator}"/>
                     </filterset>
                 </copy>
                 <chmod file="@{bin.dir}/@{name}" perm="ugo+rx"/>
@@ -833,7 +835,8 @@
                executable="${boot.java.home}/bin/javac"
                srcdir="${make.tools.dir}/CompileProperties"
                destdir="${build.toolclasses.dir}/"
-               classpath="${ant.home}/lib/ant.jar"/>
+               classpath="${ant.core.lib}"
+               includeantruntime="false"/>
         <taskdef name="pcompile"
                  classname="CompilePropertiesTask"
                  classpath="${build.toolclasses.dir}/"/>
@@ -847,7 +850,8 @@
                executable="${boot.java.home}/bin/javac"
                srcdir="${make.tools.dir}/GenStubs"
                destdir="${build.toolclasses.dir}/"
-               classpath="${build.bootstrap.dir}/classes:${ant.home}/lib/ant.jar"/>
+               classpath="${build.bootstrap.dir}/classes:${ant.core.lib}"
+               includeantruntime="false"/>
         <taskdef name="genstubs"
                  classname="GenStubs$$Ant"
                  classpath="${build.toolclasses.dir}/"/>
@@ -956,7 +960,8 @@
         <taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
     </target>
 
-    <target name="-def-findbugs" unless="findbugs.defined" depends="-check-findbugs.home">
+    <target name="-def-findbugs" unless="findbugs.defined"
+        depends="-check-findbugs.home,-check-target.java.home">
         <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask">
             <classpath>
                 <pathelement location="${findbugs.home}/lib/findbugs.jar"/>
@@ -976,6 +981,7 @@
                     failOnError="false"
                     errorProperty="findbugs.@{name}.errors"
                     warningsProperty="findbugs.@{name}.warnings"
+                    jvm="${target.java.home}/bin/java"
                     jvmargs="-Xmx512M" >
                     <class location="${dist.dir}/lib/@{name}.jar"/>
                     <auxClasspath>
--- a/make/jprt.properties	Mon Oct 18 17:21:50 2010 +0100
+++ b/make/jprt.properties	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -24,31 +24,13 @@
 #
 
 # Properties for jprt
-jprt.tools.default.release=jdk1.7.0
 
-# Specific platform list
-jprt.build.platforms=\
-solaris_sparc_5.10,\
-solaris_sparcv9_5.10,\
-solaris_i586_5.10,\
-solaris_x64_5.10,\
-linux_i586_2.6,\
-linux_x64_2.6,\
-windows_i586,\
-windows_x64
+# Use whatever release that the submitted job requests
+jprt.tools.default.release=${jprt.submit.release}
 
-# The different build flavors we want
+# The different build flavors we want, we override here so we just get these 2
 jprt.build.flavors=product,fastdebug
 
-# Explicitly designate what the 32bit match is for the 64bit build
-jprt.solaris_sparcv9.build.platform.match32=solaris_sparc_5.10
-jprt.solaris_sparcv9_5.10.build.platform.match32=solaris_sparc_5.10
-jprt.solaris_x64.build.platform.match32=solaris_i586_5.10
-jprt.solaris_x64_5.10.build.platform.match32=solaris_i586_5.10
+# Directories to be excluded from the source bundles
+jprt.bundle.exclude.src.dirs=build dist webrev
 
-# Standard list of jprt test targets for this workspace
-jprt.test.targets=
-
-# Directories needed to build
-jprt.bundle.exclude.src.dirs=build dist
-
--- a/make/netbeans/langtools/build.xml	Mon Oct 18 17:21:50 2010 +0100
+++ b/make/netbeans/langtools/build.xml	Tue Oct 19 16:26:29 2010 +0100
@@ -31,44 +31,44 @@
 -->
 
 <project name="langtools-netbeans" default="build" basedir="../../..">
-    
-    <property name="langtools.properties" 
+
+    <property name="langtools.properties"
         location="make/netbeans/langtools/nbproject/private/langtools.properties"/>
-    
-    <!-- 
+
+    <!--
         Instead of importing the main build file, we could call it when needed.
         That would reduce the list of Ant targets that get displayed for this
-        file, but it also complicates the interface between the project build 
+        file, but it also complicates the interface between the project build
         file and the main build file. For example, some imported targets
         would have to be reclared, properties would have to be restructured,
-        and it would be harder to run results (e.g. in properties) from nested 
+        and it would be harder to run results (e.g. in properties) from nested
         targets.
      -->
-    <import file="../../build.xml"/> 
-    
+    <import file="../../build.xml"/>
+
     <!-- Build project. (action: build; F11)
         If langtools.tool.name is set, then just build that tool; otherwise
         build all tools.
     -->
-    
-    <target name="build" depends="-get-tool-if-set,-build-tool,-build-all" 
+
+    <target name="build" depends="-get-tool-if-set,-build-tool,-build-all"
         description="Build one or all langtools tools"
         />
-        
+
     <target name="-build-tool" if="langtools.tool.name">
         <echo level="info" message="Building ${langtools.tool.name}"/>
         <echo level="verbose" message="(Unset langtools.tool.name to build all tools)"/>
         <antcall target="build-${langtools.tool.name}"/>
     </target>
-    
+
     <target name="-build-all" unless="langtools.tool.name">
         <echo level="info" message="Building all tools"/>
         <echo level="verbose" message="(Set langtools.tool.name to build a single tool)"/>
         <antcall target="build-all-tools"/>
     </target>
-    
+
     <!-- Compile a single file. (action: compile.single; F9) -->
-    
+
     <target name="compile-single" depends="build-bootstrap-javac">
         <fail unless="includes">Must set property 'includes'</fail>
         <javac fork="true" executable="${build.bootstrap.dir}/bin/javac"
@@ -78,38 +78,38 @@
                sourcepath=""
                includeAntRuntime="no"
                target="${javac.target}"
-               debug="${javac.debug}" 
+               debug="${javac.debug}"
                debuglevel="${javac.debuglevel}"/>
     </target>
-    
-    <!-- Run tool. (action: run; F6) 
+
+    <!-- Run tool. (action: run; F6)
         Use langtools.tool.name and langtools.tool.args properties if set; otherwise prompt
         the user.
     -->
-    
-    <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args" 
+
+    <target name="run" depends="-check-target.java.home,build,-def-run,-get-tool-and-args"
             description="run tool">
         <echo level="info" message="Run ${langtools.tool.name} with args ${langtools.tool.args}"/>
         <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}"/>
     </target>
-    
+
     <!-- Run a selected class. (action: run.single;  shift-F6) -->
-    
+
     <target name="run-single" depends="-check-target.java.home,-def-run">
         <fail unless="run.classname">Must set property 'run.classname' </fail>
         <echo level="info" message="run ${run.classname}"/>
         <run mainclass="${run.classname}" args=""/>
     </target>
-    
+
     <!-- Test project, and display results if tests failed. (action: test; Alt-F6)
         If langtools.tool.name is set, then just test that tool; otherwise
         test all tools.
     -->
-    
-    <target name="jtreg" depends="-get-tool-if-set,-jtreg-tool,-jtreg-all" 
+
+    <target name="jtreg" depends="-get-tool-if-set,-jtreg-tool,-jtreg-all"
         description="Test one or all langtools tools"
         />
-    
+
     <target name="-jtreg-tool" if="langtools.tool.name">
         <echo level="info" message="Testing ${langtools.tool.name}"/>
         <echo level="verbose" message="(Unset langtools.tool.name to test all tools)"/>
@@ -118,7 +118,7 @@
             <target name="-show-jtreg"/>
         </antcall>
     </target>
-    
+
     <target name="-jtreg-all" unless="langtools.tool.name">
         <echo level="info" message="Testing all tools"/>
         <echo level="verbose" message="(Set langtools.tool.name to test a single tool)"/>
@@ -127,36 +127,36 @@
             <target name="-show-jtreg"/>
         </antcall>
     </target>
-    
+
     <target name="-show-jtreg" if="netbeans.home" unless="jtreg.passed">
         <nbbrowse file="${jtreg.report}/report.html"/>
         <fail>Some tests failed; see report for details.</fail>
     </target>
-    
+
     <!-- Debug tool in NetBeans. -->
-    
+
     <target name="debug" depends="-check-target.java.home,-def-run,-def-start-debugger,-get-tool-and-args,build" if="netbeans.home">
         <echo level="info" message="Debug ${langtools.tool.name} with args ${langtools.tool.args}"/>
         <start-debugger/>
         <run mainclass="com.sun.tools.${langtools.tool.name}.Main" args="${langtools.tool.args}" jpda.jvmargs="${jpda.jvmargs}"/>
     </target>
-    
+
     <!-- Debug a selected class . -->
     <target name="debug-single" depends="-check-target.java.home,-def-start-debugger,-def-run">
         <fail unless="debug.classname">Must set property 'debug.classname'</fail>
         <start-debugger/>
         <run mainclass="${debug.classname}" default.args="" jpda.jvmargs="${jpda.jvmargs}"/>
     </target>
-    
+
     <!-- Debug a jtreg test. -->
     <target name="debug-jtreg" depends="-check-target.java.home,-def-start-debugger,-def-jtreg">
         <fail unless="jtreg.tests">Must set property 'jtreg.tests'</fail>
         <start-debugger/>
         <jtreg-tool name="debug" samevm="false" tests="${jtreg.tests}" jpda.jvmargs="${jpda.jvmargs}"/>
     </target>
-    
+
     <!-- Update a class being debugged. -->
-    
+
     <target name="debug-fix" if="langtools.tool.name">
         <fail unless="class">Must set property 'class'
         </fail>
@@ -169,16 +169,16 @@
             </fileset>
         </nbjpdareload>
     </target>
-    
+
     <!-- Generate javadoc for one or all tools. (action: javadoc; Alt-F6)
         If langtools.tool.name is set, then just test that tool; otherwise
         test all tools.
     -->
-    
-    <target name="javadoc" depends="-javadoc-tool,-javadoc-all" 
+
+    <target name="javadoc" depends="-javadoc-tool,-javadoc-all"
         description="Generate javadoc for one or all langtools tools"
         />
-        
+
     <target name="-javadoc-tool" if="langtools.tool.name">
         <echo level="info" message="Generate javadoc for ${langtools.tool.name}"/>
         <echo level="verbose" message="(Unset langtools.tool.name to generate javadoc for all tools)"/>
@@ -187,7 +187,7 @@
             <target name="-show-javadoc"/>
         </antcall>
     </target>
-    
+
     <target name="-javadoc-all" unless="langtools.tool.name">
         <echo level="info" message="Generate javadoc for all tools"/>
         <echo level="verbose" message="(Set langtools.tool.name to generate javadoc for a single tool)"/>
@@ -196,26 +196,26 @@
             <target name="-show-javadoc"/>
         </antcall>
     </target>
-    
+
     <target name="-show-javadoc" if="netbeans.home">
         <!-- what if doing javadoc for all? -->
         <nbbrowse file="${build.javadoc.dir}/${langtools.tool.name}/index.html"/>
     </target>
-    
+
     <!-- Prompt for values. -->
-    
+
     <target name="-get-tool-if-set" depends="-def-select-tool">
-        <select-tool 
-            toolproperty="langtools.tool.name" 
+        <select-tool
+            toolproperty="langtools.tool.name"
             propertyfile="${langtools.properties}"
             askIfUnset="false"
             />
     </target>
-    
+
     <target name="-get-tool-and-args" depends="-def-select-tool">
-        <select-tool 
-            toolproperty="langtools.tool.name" 
-            argsproperty="langtools.tool.args" 
+        <select-tool
+            toolproperty="langtools.tool.name"
+            argsproperty="langtools.tool.args"
             propertyfile="${langtools.properties}"
             askIfUnset="true"
             />
@@ -236,7 +236,7 @@
             </sequential>
         </macrodef>
     </target>
-    
+
     <!-- Macro to start the debugger and set a property containg the args needed by the run task -->
     <target name="-def-start-debugger" if="netbeans.home">
         <macrodef name="start-debugger">
@@ -251,28 +251,29 @@
                         <pathelement location="${src.classes.dir}"/>
                     </sourcepath>
                 </nbjpdastart>
-                <property 
-                    name="@{jpda.jvmargs.property}" 
+                <property
+                    name="@{jpda.jvmargs.property}"
                     value="-Xdebug -Xnoagent -Djava.compiler=none -Xrunjdwp:transport=dt_socket,address=${jpda.address}"
                 />
             </sequential>
         </macrodef>
     </target>
-    
+
     <target name="-def-select-tool">
         <mkdir dir="${build.toolclasses.dir}"/>
         <javac srcdir="${make.tools.dir}/SelectTool"
                destdir="${build.toolclasses.dir}/"
-               classpath="${ant.home}/lib/ant.jar"
-               debug="${javac.debug}" 
+               classpath="${ant.core.lib}"
+               includeantruntime="false"
+               debug="${javac.debug}"
                debuglevel="${javac.debuglevel}">
                    <compilerarg line="-Xlint"/>
         </javac>
         <taskdef name="select-tool"
-                 classname="SelectToolTask" 
+                 classname="SelectToolTask"
                  classpath="${build.toolclasses.dir}/"/>
     </target>
-        
+
     <target name="select-tool" depends="-def-select-tool">
         <select-tool propertyfile="${langtools.properties}"/>
     </target>
--- a/src/share/bin/launcher.sh-template	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/bin/launcher.sh-template	Tue Oct 19 16:26:29 2010 +0100
@@ -40,8 +40,8 @@
 if [ "$LANGTOOLS_USE_BOOTCLASSPATH" != "no" ]; then
    cp=`unzip -c "$mylib/#PROGRAM#.jar" META-INF/MANIFEST.MF |
        grep "Class-Path:" |
-       sed -e 's|Class-Path: *||' -e 's|\([a-z]*\.jar\) *|'"$mylib"'/\1:|g'`
-   bcp="$mylib/#PROGRAM#.jar"
+       sed -e 's|Class-Path: *||' -e 's|\([a-z]*\.jar\) *|'"$mylib"'/\1#PS#:|g'`
+   bcp="$mylib/#PROGRAM#.jar#PS#$cp"
 fi
 
 # tools currently assumes that assertions are enabled in the launcher
--- a/src/share/classes/com/sun/source/tree/Tree.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/source/tree/Tree.java	Tue Oct 19 16:26:29 2010 +0100
@@ -94,7 +94,7 @@
         CATCH(CatchTree.class),
 
         /**
-         * Used for instances of {@link ClassTree}.
+         * Used for instances of {@link ClassTree} representing classes.
          */
         CLASS(ClassTree.class),
 
@@ -573,6 +573,21 @@
         ERRONEOUS(ErroneousTree.class),
 
         /**
+         * Used for instances of {@link ClassTree} representing interfaces.
+         */
+        INTERFACE(ClassTree.class),
+
+        /**
+         * Used for instances of {@link ClassTree} representing enums.
+         */
+        ENUM(ClassTree.class),
+
+        /**
+         * Used for instances of {@link ClassTree} representing annotation types.
+         */
+        ANNOTATION_TYPE(ClassTree.class),
+
+        /**
          * An implementation-reserved node. This is the not the node
          * you are looking for.
          */
--- a/src/share/classes/com/sun/source/util/TreeScanner.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/source/util/TreeScanner.java	Tue Oct 19 16:26:29 2010 +0100
@@ -141,6 +141,7 @@
         r = scanAndReduce(node.getReceiverAnnotations(), p, r);
         r = scanAndReduce(node.getThrows(), p, r);
         r = scanAndReduce(node.getBody(), p, r);
+        r = scanAndReduce(node.getDefaultValue(), p, r);
         return r;
     }
 
--- a/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,9 +99,6 @@
     private static Context preRegister(Context context) {
         Bark.preRegister(context);
 
-        // force the use of the scanner that captures Javadoc comments
-        DocCommentScanner.Factory.preRegister(context);
-
         if (context.get(JavaFileManager.class) == null)
             JavacFileManager.preRegister(context);
 
--- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -96,9 +96,6 @@
         args.getClass();
         context.getClass();
         fileObjects.getClass();
-
-        // force the use of the scanner that captures Javadoc comments
-        com.sun.tools.javac.parser.DocCommentScanner.Factory.preRegister(context);
     }
 
     JavacTaskImpl(JavacTool tool,
@@ -337,9 +334,13 @@
 
             ListBuffer<TypeElement> elements = new ListBuffer<TypeElement>();
             for (JCCompilationUnit unit : units) {
-                for (JCTree node : unit.defs)
-                    if (node.getTag() == JCTree.CLASSDEF)
-                        elements.append(((JCTree.JCClassDecl) node).sym);
+                for (JCTree node : unit.defs) {
+                    if (node.getTag() == JCTree.CLASSDEF) {
+                        JCClassDecl cdef = (JCClassDecl) node;
+                        if (cdef.sym != null) // maybe null if errors in anno processing
+                            elements.append(cdef.sym);
+                    }
+                }
             }
             return elements.toList();
         }
--- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -45,6 +45,7 @@
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
 import com.sun.source.util.Trees;
+import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.TypeSymbol;
 import com.sun.tools.javac.code.Symbol;
@@ -55,7 +56,6 @@
 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.processing.JavacMessager;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.tree.JCTree;
@@ -80,14 +80,15 @@
  */
 public class JavacTrees extends Trees {
 
-    private final Resolve resolve;
-    private final Enter enter;
-    private final Log log;
-    private final MemberEnter memberEnter;
-    private final Attr attr;
-    private final TreeMaker treeMaker;
-    private final JavacElements elements;
-    private final JavacTaskImpl javacTaskImpl;
+    // in a world of a single context per compilation, these would all be final
+    private Resolve resolve;
+    private Enter enter;
+    private Log log;
+    private MemberEnter memberEnter;
+    private Attr attr;
+    private TreeMaker treeMaker;
+    private JavacElements elements;
+    private JavacTaskImpl javacTaskImpl;
 
     public static JavacTrees instance(JavaCompiler.CompilationTask task) {
         if (!(task instanceof JavacTaskImpl))
@@ -110,6 +111,14 @@
 
     private JavacTrees(Context context) {
         context.put(JavacTrees.class, this);
+        init(context);
+    }
+
+    public void updateContext(Context context) {
+        init(context);
+    }
+
+    private void init(Context context) {
         attr = Attr.instance(context);
         enter = Enter.instance(context);
         elements = JavacElements.instance(context);
@@ -189,8 +198,24 @@
     }
 
     public Element getElement(TreePath path) {
-        Tree t = path.getLeaf();
-        return TreeInfo.symbolFor((JCTree) t);
+        JCTree tree = (JCTree) path.getLeaf();
+        Symbol sym = TreeInfo.symbolFor(tree);
+        if (sym == null && TreeInfo.isDeclaration(tree)) {
+            for (TreePath p = path; p != null; p = p.getParentPath()) {
+                JCTree t = (JCTree) p.getLeaf();
+                if (t.getTag() == JCTree.CLASSDEF) {
+                    JCClassDecl ct = (JCClassDecl) t;
+                    if (ct.sym != null) {
+                        if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) {
+                            attr.attribClass(ct.pos(), ct.sym);
+                            sym = TreeInfo.symbolFor(tree);
+                        }
+                        break;
+                    }
+                }
+            }
+        }
+        return sym;
     }
 
     public TypeMirror getTypeMirror(TreePath path) {
@@ -258,6 +283,8 @@
                     env = enter.getTopLevelEnv((JCCompilationUnit)tree);
                     break;
                 case CLASS:
+                case INTERFACE:
+                case ENUM:
 //                    System.err.println("CLASS: " + ((JCClassDecl)tree).sym.getSimpleName());
                     env = enter.getClassEnv(((JCClassDecl)tree).sym);
                     break;
@@ -318,6 +345,7 @@
             super(M);
         }
 
+        @Override
         public <T extends JCTree> T copy(T t, JCTree leaf) {
             T t2 = super.copy(t, leaf);
             if (t == leaf)
--- a/src/share/classes/com/sun/tools/javac/code/Attribute.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java	Tue Oct 19 16:26:29 2010 +0100
@@ -295,4 +295,11 @@
         void visitEnum(Attribute.Enum e);
         void visitError(Attribute.Error e);
     }
+
+    /** A mirror of java.lang.annotation.RetentionPolicy. */
+    public static enum RetentionPolicy {
+        SOURCE,
+        CLASS,
+        RUNTIME
+    }
 }
--- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Tue Oct 19 16:26:29 2010 +0100
@@ -268,6 +268,12 @@
      */
     public static final long EFFECTIVELY_FINAL = 1L<<45;
 
+    /**
+     * Flag that marks a special kind of bridge methods (the ones that
+     * come from restricted supertype bounds)
+     */
+    public static final long OVERRIDE_BRIDGE = 1L<<41;
+
     /** Modifier masks.
      */
     public static final int
--- a/src/share/classes/com/sun/tools/javac/code/Scope.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Scope.java	Tue Oct 19 16:26:29 2010 +0100
@@ -70,6 +70,45 @@
      */
     public int nelems = 0;
 
+    /** A timestamp - useful to quickly check whether a scope has changed or not
+     */
+    public ScopeCounter scopeCounter;
+
+    static ScopeCounter dummyCounter = new ScopeCounter() {
+        @Override
+        public void inc() {
+            //do nothing
+        }
+    };
+
+    public static class ScopeCounter {
+        protected static final Context.Key<ScopeCounter> scopeCounterKey =
+            new Context.Key<ScopeCounter>();
+
+        public static ScopeCounter instance(Context context) {
+            ScopeCounter instance = context.get(scopeCounterKey);
+            if (instance == null)
+                instance = new ScopeCounter(context);
+            return instance;
+        }
+
+        protected ScopeCounter(Context context) {
+            context.put(scopeCounterKey, this);
+        }
+
+        private ScopeCounter() {};
+
+        private long val = 0;
+
+        public void inc() {
+            val++;
+        }
+
+        public long val() {
+            return val;
+        }
+    }
+
     /** Every hash bucket is a list of Entry's which ends in sentinel.
      */
     private static final Entry sentinel = new Entry(null, null, null, null);
@@ -80,12 +119,12 @@
 
     /** A value for the empty scope.
      */
-    public static final Scope emptyScope = new Scope(null, null, new Entry[]{});
+    public static final Scope emptyScope = new Scope(null, null, new Entry[]{}, dummyCounter);
 
     /** Construct a new scope, within scope next, with given owner, using
      *  given table. The table's length must be an exponent of 2.
      */
-    Scope(Scope next, Symbol owner, Entry[] table) {
+    private Scope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
         this.next = next;
         assert emptyScope == null || owner != null;
         this.owner = owner;
@@ -94,13 +133,18 @@
         this.elems = null;
         this.nelems = 0;
         this.shared = 0;
+        this.scopeCounter = scopeCounter;
     }
 
     /** Construct a new scope, within scope next, with given owner,
      *  using a fresh table of length INITIAL_SIZE.
      */
     public Scope(Symbol owner) {
-        this(null, owner, new Entry[INITIAL_SIZE]);
+        this(owner, dummyCounter);
+    }
+
+    protected Scope(Symbol owner, ScopeCounter scopeCounter) {
+        this(null, owner, new Entry[INITIAL_SIZE], scopeCounter);
         for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel;
     }
 
@@ -110,7 +154,7 @@
      *  of fresh tables.
      */
     public Scope dup() {
-        Scope result = new Scope(this, this.owner, this.table);
+        Scope result = new Scope(this, this.owner, this.table, scopeCounter);
         shared++;
         // System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode());
         // new Error().printStackTrace(System.out);
@@ -123,7 +167,7 @@
      *  of fresh tables.
      */
     public Scope dup(Symbol newOwner) {
-        Scope result = new Scope(this, newOwner, this.table);
+        Scope result = new Scope(this, newOwner, this.table, scopeCounter);
         shared++;
         // System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode());
         // new Error().printStackTrace(System.out);
@@ -135,7 +179,7 @@
      *  the table of its outer scope.
      */
     public Scope dupUnshared() {
-        return new Scope(this, this.owner, this.table.clone());
+        return new Scope(this, this.owner, this.table.clone(), scopeCounter);
     }
 
     /** Remove all entries of this scope from its table, if shared
@@ -211,6 +255,7 @@
         table[hash] = e;
         elems = e;
         nelems++;
+        scopeCounter.inc();
     }
 
     Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
@@ -226,6 +271,8 @@
         while (e.scope == this && e.sym != sym) e = e.next();
         if (e.scope == null) return;
 
+        scopeCounter.inc();
+
         // remove e from table and shadowed list;
         Entry te = table[sym.name.hashCode() & hashMask];
         if (te == e)
@@ -272,6 +319,12 @@
         return false;
     }
 
+    static final Filter<Symbol> noFilter = new Filter<Symbol>() {
+        public boolean accepts(Symbol s) {
+            return true;
+        }
+    };
+
     /** Return the entry associated with given name, starting in
      *  this scope and proceeding outwards. If no entry was found,
      *  return the sentinel, which is characterized by having a null in
@@ -279,13 +332,20 @@
      *  for regular entries.
      */
     public Entry lookup(Name name) {
+        return lookup(name, noFilter);
+    }
+    public Entry lookup(Name name, Filter<Symbol> sf) {
         Entry e = table[name.hashCode() & hashMask];
-        while (e.scope != null && e.sym.name != name)
+        while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym)))
             e = e.shadowed;
         return e;
     }
 
     public Iterable<Symbol> getElements() {
+        return getElements(noFilter);
+    }
+
+    public Iterable<Symbol> getElements(final Filter<Symbol> sf) {
         return new Iterable<Symbol>() {
             public Iterator<Symbol> iterator() {
                 return new Iterator<Symbol>() {
@@ -301,7 +361,9 @@
 
                     public Symbol next() {
                         Symbol sym = (currEntry == null ? null : currEntry.sym);
-                        currEntry = currEntry.sibling;
+                        if (currEntry != null) {
+                            currEntry = currEntry.sibling;
+                        }
                         update();
                         return sym;
                     }
@@ -311,9 +373,17 @@
                     }
 
                     private void update() {
+                        skipToNextMatchingEntry();
                         while (currEntry == null && currScope.next != null) {
                             currScope = currScope.next;
                             currEntry = currScope.elems;
+                            skipToNextMatchingEntry();
+                        }
+                    }
+
+                    void skipToNextMatchingEntry() {
+                        while (currEntry != null && !sf.accepts(currEntry.sym)) {
+                            currEntry = currEntry.sibling;
                         }
                     }
                 };
@@ -449,7 +519,7 @@
         public static final Entry[] emptyTable = new Entry[0];
 
         public DelegatedScope(Scope outer) {
-            super(outer, outer.owner, emptyTable);
+            super(outer, outer.owner, emptyTable, outer.scopeCounter);
             delegatee = outer;
         }
         public Scope dup() {
@@ -475,10 +545,22 @@
         }
     }
 
+    /** A class scope, for which a scope counter should be provided */
+    public static class ClassScope extends Scope {
+
+        ClassScope(Scope next, Symbol owner, Entry[] table, ScopeCounter scopeCounter) {
+            super(next, owner, table, scopeCounter);
+        }
+
+        public ClassScope(Symbol owner, ScopeCounter scopeCounter) {
+            super(owner, scopeCounter);
+        }
+    }
+
     /** An error scope, for which the owner should be an error symbol. */
     public static class ErrorScope extends Scope {
         ErrorScope(Scope next, Symbol errSymbol, Entry[] table) {
-            super(next, /*owner=*/errSymbol, table);
+            super(next, /*owner=*/errSymbol, table, dummyCounter);
         }
         public ErrorScope(Symbol errSymbol) {
             super(errSymbol);
--- a/src/share/classes/com/sun/tools/javac/code/Source.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Tue Oct 19 16:26:29 2010 +0100
@@ -25,11 +25,14 @@
 
 package com.sun.tools.javac.code;
 
+import java.util.*;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.jvm.Target;
-import javax.lang.model.SourceVersion;
-import static javax.lang.model.SourceVersion.*;
-import java.util.*;
+
+import static com.sun.tools.javac.main.OptionName.*;
 
 /** The source language version accepted.
  *
@@ -71,7 +74,7 @@
         Source instance = context.get(sourceKey);
         if (instance == null) {
             Options options = Options.instance(context);
-            String sourceString = options.get("-source");
+            String sourceString = options.get(SOURCE);
             if (sourceString != null) instance = lookup(sourceString);
             if (instance == null) instance = DEFAULT;
             context.put(sourceKey, instance);
@@ -174,11 +177,10 @@
     public boolean allowUnderscoresInLiterals() {
         return compareTo(JDK1_7) >= 0;
     }
-    public boolean allowStringsInSwitch() {
+    public boolean allowExoticIdentifiers() {
         return compareTo(JDK1_7) >= 0;
     }
-    // JSR 292: recognize @PolymorphicSignature on java/dyn names
-    public boolean allowPolymorphicSignature() {
+    public boolean allowStringsInSwitch() {
         return compareTo(JDK1_7) >= 0;
     }
     public boolean allowLambda() {
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -214,6 +214,16 @@
         return (flags() & INTERFACE) != 0;
     }
 
+    /** Recognize if this symbol was marked @PolymorphicSignature in the source. */
+    public boolean isPolymorphicSignatureGeneric() {
+        return (flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == POLYMORPHIC_SIGNATURE;
+    }
+
+    /** Recognize if this symbol was split from a @PolymorphicSignature symbol in the source. */
+    public boolean isPolymorphicSignatureInstance() {
+        return (flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == (POLYMORPHIC_SIGNATURE | HYPOTHETICAL);
+    }
+
     /** Is this symbol declared (directly or indirectly) local
      *  to a method or variable initializer?
      *  Also includes fields of inner classes which are in
@@ -579,6 +589,9 @@
 
         public java.util.List<Symbol> getEnclosedElements() {
             List<Symbol> list = List.nil();
+            if (kind == TYP && type.tag == TYPEVAR) {
+                return list;
+            }
             for (Scope.Entry e = members().elems; e != null; e = e.sibling) {
                 if (e.sym != null && (e.sym.flags() & SYNTHETIC) == 0 && e.sym.owner == this)
                     list = list.prepend(e.sym);
@@ -947,6 +960,8 @@
                 return ElementKind.ENUM_CONSTANT;
             } else if (owner.kind == TYP || owner.kind == ERR) {
                 return ElementKind.FIELD;
+            } else if (isResourceVariable()) {
+                return ElementKind.RESOURCE_VARIABLE;
             } else {
                 return ElementKind.LOCAL_VARIABLE;
             }
@@ -1220,7 +1235,18 @@
          *  as possible implementations.
          */
         public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) {
-            MethodSymbol res = types.implementation(this, origin, types, checkResult);
+            return implementation(origin, types, checkResult, implementation_filter);
+        }
+        // where
+            private static final Filter<Symbol> implementation_filter = new Filter<Symbol>() {
+                public boolean accepts(Symbol s) {
+                    return s.kind == Kinds.MTH &&
+                            (s.flags() & SYNTHETIC) == 0;
+                }
+            };
+
+        public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
+            MethodSymbol res = types.implementation(this, origin, types, checkResult, implFilter);
             if (res != null)
                 return res;
             // if origin is derived from a raw type, we might have missed
--- a/src/share/classes/com/sun/tools/javac/code/Symtab.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Tue Oct 19 16:26:29 2010 +0100
@@ -74,6 +74,7 @@
     public final JCNoType voidType = new JCNoType(TypeTags.VOID);
 
     private final Names names;
+    private final Scope.ScopeCounter scopeCounter;
     private final ClassReader reader;
     private final Target target;
 
@@ -93,6 +94,10 @@
      */
     public final ClassSymbol errSymbol;
 
+    /** The unknown symbol.
+     */
+    public final ClassSymbol unknownSymbol;
+
     /** A value for the errType, with a originalType of noType */
     public final Type errType;
 
@@ -344,6 +349,7 @@
         context.put(symtabKey, this);
 
         names = Names.instance(context);
+        scopeCounter = Scope.ScopeCounter.instance(context);
         target = Target.instance(context);
 
         // Create the unknown type
@@ -362,6 +368,7 @@
 
         // create the error symbols
         errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
+        unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
         errType = new ErrorType(errSymbol, Type.noType);
 
         // initialize builtin types
@@ -376,7 +383,7 @@
         initType(voidType, "void", "Void");
         initType(botType, "<nulltype>");
         initType(errType, errSymbol);
-        initType(unknownType, "<any?>");
+        initType(unknownType, unknownSymbol);
 
         // the builtin class of all arrays
         arrayClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Array, noSymbol);
@@ -392,7 +399,7 @@
 
         // Create class to hold all predefined constants and operations.
         predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
-        Scope scope = new Scope(predefClass);
+        Scope scope = new Scope.ClassScope(predefClass, scopeCounter);
         predefClass.members_field = scope;
 
         // Enter symbols for basic types.
@@ -487,7 +494,7 @@
         proprietarySymbol.completer = null;
         proprietarySymbol.flags_field = PUBLIC|ACYCLIC|ANNOTATION|INTERFACE;
         proprietarySymbol.erasure_field = proprietaryType;
-        proprietarySymbol.members_field = new Scope(proprietarySymbol);
+        proprietarySymbol.members_field = new Scope.ClassScope(proprietarySymbol, scopeCounter);
         proprietaryType.typarams_field = List.nil();
         proprietaryType.allparams_field = List.nil();
         proprietaryType.supertype_field = annotationType;
@@ -499,7 +506,7 @@
         ClassType arrayClassType = (ClassType)arrayClass.type;
         arrayClassType.supertype_field = objectType;
         arrayClassType.interfaces_field = List.of(cloneableType, serializableType);
-        arrayClass.members_field = new Scope(arrayClass);
+        arrayClass.members_field = new Scope.ClassScope(arrayClass, scopeCounter);
         lengthVar = new VarSymbol(
             PUBLIC | FINAL,
             names.length,
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Tue Oct 19 16:26:29 2010 +0100
@@ -332,6 +332,10 @@
         return (tsym.flags() & INTERFACE) != 0;
     }
 
+    public boolean isFinal() {
+        return (tsym.flags() & FINAL) != 0;
+    }
+
     public boolean isPrimitive() {
         return tag < VOID;
     }
@@ -351,11 +355,17 @@
         return false;
     }
 
-    /** Does this type contain an occurrence of some type in `elems'?
+    /** Does this type contain an occurrence of some type in 'ts'?
      */
-    public boolean containsSome(List<Type> ts) {
-        for (List<Type> l = ts; l.nonEmpty(); l = l.tail)
-            if (this.contains(ts.head)) return true;
+    public boolean containsAny(List<Type> ts) {
+        for (Type t : ts)
+            if (this.contains(t)) return true;
+        return false;
+    }
+
+    public static boolean containsAny(List<Type> ts1, List<Type> ts2) {
+        for (Type t : ts1)
+            if (t.containsAny(ts2)) return true;
         return false;
     }
 
@@ -435,6 +445,10 @@
             this.bound = bound;
         }
 
+        public boolean contains(Type t) {
+            return kind != UNBOUND && type.contains(t);
+        }
+
         public boolean isSuperBound() {
             return kind == SUPER ||
                 kind == UNBOUND;
@@ -689,7 +703,9 @@
             return
                 elem == this
                 || (isParameterized()
-                    && (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem)));
+                    && (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem)))
+                || (isCompound()
+                    && (supertype_field.contains(elem) || contains(interfaces_field, elem)));
         }
 
         public void complete() {
--- a/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Tue Oct 19 16:26:29 2010 +0100
@@ -114,6 +114,8 @@
                     return p;
 
                 case CLASS:
+                case INTERFACE:
+                case ENUM:
                     p.pos = frame.pos;
                     if (((JCClassDecl)frame).extending == tree) {
                         p.type = TargetType.CLASS_EXTENDS;
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Oct 19 16:26:29 2010 +0100
@@ -32,6 +32,7 @@
 import com.sun.tools.javac.util.List;
 
 import com.sun.tools.javac.jvm.ClassReader;
+import com.sun.tools.javac.code.Attribute.RetentionPolicy;
 import com.sun.tools.javac.comp.Check;
 import com.sun.tools.javac.comp.Env;
 import com.sun.tools.javac.comp.Resolve;
@@ -71,6 +72,7 @@
         new Context.Key<Types>();
 
     final Symtab syms;
+    final Scope.ScopeCounter scopeCounter;
     final JavacMessages messages;
     final Names names;
     final boolean allowBoxing;
@@ -91,6 +93,7 @@
     protected Types(Context context) {
         context.put(typesKey, this);
         syms = Symtab.instance(context);
+        scopeCounter = Scope.ScopeCounter.instance(context);
         names = Names.instance(context);
         allowBoxing = Source.instance(context).allowBoxing();
         reader = ClassReader.instance(context);
@@ -1410,7 +1413,9 @@
     }
 
     public boolean isCastable(Env<AttrContext> env, Type t, Type s, Warner warn) {
-        if (isConvertible(env, t, s, warn))
+        if (t.isPrimitive() != s.isPrimitive())
+            return allowBoxing && (isConvertible(env, t, s, warn) || isConvertible(env, s, t, warn));
+        else if (isConvertible(env, t, s, warn))
             return true;
         else
             return isCastableReference(t, s, warn);
@@ -1468,7 +1473,7 @@
                     return true;
 
                 if (s.tag == TYPEVAR) {
-                    if (isCastableReference(s.getUpperBound(), t, Warner.noWarnings)) {
+                    if (isCastableReference(t, s.getUpperBound(), Warner.noWarnings)) {
                         warnStack.head.warnUnchecked();
                         return true;
                     } else {
@@ -1543,7 +1548,12 @@
                                 && !disjointTypes(aHigh.allparams(), lowSub.allparams())
                                 && !disjointTypes(aLow.allparams(), highSub.allparams())
                                 && !disjointTypes(aLow.allparams(), lowSub.allparams())) {
-                                if (upcast ? giveWarning(a, b) :
+                                if (s.isInterface() &&
+                                        !t.isInterface() &&
+                                        t.isFinal() &&
+                                        !isSubtype(t, s)) {
+                                    return false;
+                                } else if (upcast ? giveWarning(a, b) :
                                     giveWarning(b, a))
                                     warnStack.head.warnUnchecked();
                                 return true;
@@ -1758,18 +1768,23 @@
         if (t == s) return false;
         if (t.tag == TYPEVAR) {
             TypeVar tv = (TypeVar) t;
-            if (s.tag == TYPEVAR)
-                s = s.getUpperBound();
             return !isCastableReference(tv.bound,
-                               s,
+                               relaxBound(s),
                                Warner.noWarnings);
         }
         if (s.tag != WILDCARD)
             s = upperBound(s);
-        if (s.tag == TYPEVAR)
-            s = s.getUpperBound();
-
-        return !isSubtype(t, s);
+
+        return !isSubtype(t, relaxBound(s));
+    }
+
+    private Type relaxBound(Type t) {
+        if (t.tag == TYPEVAR) {
+            while (t.tag == TYPEVAR)
+                t = t.getUpperBound();
+            t = rewriteQuantifiers(t, true, true);
+        }
+        return t;
     }
     // </editor-fold>
 
@@ -2531,63 +2546,91 @@
             hasSameArgs(t, erasure(s)) || hasSameArgs(erasure(t), s);
     }
 
-    private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>> implCache_check =
-            new WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>>();
-
-    private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>> implCache_nocheck =
-            new WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>>();
-
-    public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult) {
-        Map<MethodSymbol, SoftReference<Map<TypeSymbol, MethodSymbol>>> implCache = checkResult ?
-            implCache_check : implCache_nocheck;
-        SoftReference<Map<TypeSymbol, MethodSymbol>> ref_cache = implCache.get(ms);
-        Map<TypeSymbol, MethodSymbol> cache = ref_cache != null ? ref_cache.get() : null;
-        if (cache == null) {
-            cache = new HashMap<TypeSymbol, MethodSymbol>();
-            implCache.put(ms, new SoftReference<Map<TypeSymbol, MethodSymbol>>(cache));
-        }
-        MethodSymbol impl = cache.get(origin);
-        if (impl == null) {
-            impl = implementation(ms, origin, types, checkResult, cache, false);
-            if (impl == null &&
-                source.allowDefenderMethods()) {
-                impl = implementation(ms, origin, types, checkResult, cache, true);
+    // <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
+    class ImplementationCache {
+
+        private WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>> _map =
+                new WeakHashMap<MethodSymbol, SoftReference<Map<TypeSymbol, Entry>>>();
+
+        class Entry {
+            final MethodSymbol cachedImpl;
+            final Filter<Symbol> implFilter;
+            final boolean checkResult;
+            final Scope.ScopeCounter scopeCounter;
+
+            public Entry(MethodSymbol cachedImpl,
+                    Filter<Symbol> scopeFilter,
+                    boolean checkResult,
+                    Scope.ScopeCounter scopeCounter) {
+                this.cachedImpl = cachedImpl;
+                this.implFilter = scopeFilter;
+                this.checkResult = checkResult;
+                this.scopeCounter = scopeCounter;
+            }
+
+            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, Scope.ScopeCounter scopeCounter) {
+                return this.implFilter == scopeFilter &&
+                        this.checkResult == checkResult &&
+                        this.scopeCounter.val() >= scopeCounter.val();
             }
         }
-        return impl;
-    }
-
-    private MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult,
-            Map<TypeSymbol, MethodSymbol> cache, boolean defenderAllowed) {
-        boolean isInterface = origin.isInterface();
-        for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) {
-            while (t.tag == TYPEVAR)
-                t = t.getUpperBound();
-            TypeSymbol c = t.tsym;
-            for (Scope.Entry e = c.members().lookup(ms.name);
-                 e.scope != null;
-                 e = e.next()) {
-                if (e.sym.kind == Kinds.MTH) {
-                    MethodSymbol m = (MethodSymbol) e.sym;
-                    if (m.overrides(ms, origin, types, checkResult) &&
-                        (m.flags() & SYNTHETIC) == 0 &&
-                        (!defenderAllowed || !isInterface || (m.flags() & DEFENDER) != 0)) {
-                        cache.put(origin, m);
-                        return m;
+
+        MethodSymbol get(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter, Scope.ScopeCounter scopeCounter) {
+            SoftReference<Map<TypeSymbol, Entry>> ref_cache = _map.get(ms);
+            Map<TypeSymbol, Entry> cache = ref_cache != null ? ref_cache.get() : null;
+            if (cache == null) {
+                cache = new HashMap<TypeSymbol, Entry>();
+                _map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
+            }
+            Entry e = cache.get(origin);
+            if (e == null ||
+                    !e.matches(implFilter, checkResult, scopeCounter)) {
+                MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter, false);
+                if (impl == null &&
+                        source.allowDefenderMethods()) {
+                    impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter, true);
+                }
+                cache.put(origin, new Entry(impl, implFilter, checkResult, scopeCounter));
+                return impl;
+            }
+            else {
+                return e.cachedImpl;
+            }
+        }
+
+        private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter, boolean defenderAllowed) {
+            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) {
+                while (t.tag == TYPEVAR)
+                    t = t.getUpperBound();
+                TypeSymbol c = t.tsym;
+                for (Scope.Entry e = c.members().lookup(ms.name, implFilter);
+                     e.scope != null;
+                     e = e.next()) {
+                    if (e.sym != null &&
+                             e.sym.overrides(ms, origin, types, checkResult) &&
+                             (!defenderAllowed || !origin.isInterface() || (e.sym.flags() & DEFENDER) != 0))
+                        return (MethodSymbol)e.sym;
+                }
+                if (defenderAllowed) {
+                    for (Type t2 : interfaces(t)) {
+                        MethodSymbol impl = implementationInternal(ms, t2.tsym, types, checkResult, implFilter, defenderAllowed);
+                        if (impl != null) {
+                            return impl;
+                        }
                     }
                 }
             }
-            if (defenderAllowed) {
-                for (Type t2 : interfaces(t)) {
-                    MethodSymbol impl = implementation(ms, t2.tsym, types, checkResult, cache, defenderAllowed);
-                    if (impl != null)
-                        return impl;
-                }
-            }
+            return null;
         }
-        return null;
     }
 
+    private ImplementationCache implCache = new ImplementationCache();
+
+    public MethodSymbol implementation(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
+        return implCache.get(ms, origin, checkResult, implFilter, scopeCounter);
+    }
+    // </editor-fold>
+
     /**
      * Does t have the same arguments as s?  It is assumed that both
      * types are (possibly polymorphic) method types.  Monomorphic
@@ -3557,6 +3600,13 @@
     public Type capture(Type t) {
         if (t.tag != CLASS)
             return t;
+        if (t.getEnclosingType() != Type.noType) {
+            Type capturedEncl = capture(t.getEnclosingType());
+            if (capturedEncl != t.getEnclosingType()) {
+                Type type1 = memberType(capturedEncl, t.tsym);
+                t = subst(type1, t.tsym.type.getTypeArguments(), t.getTypeArguments());
+            }
+        }
         ClassType cls = (ClassType)t;
         if (cls.isRaw() || !cls.isParameterized())
             return cls;
@@ -3885,7 +3935,7 @@
      * quantifiers) only
      */
     private Type rewriteQuantifiers(Type t, boolean high, boolean rewriteTypeVars) {
-        return new Rewriter(high, rewriteTypeVars).rewrite(t);
+        return new Rewriter(high, rewriteTypeVars).visit(t);
     }
 
     class Rewriter extends UnaryVisitor<Type> {
@@ -3898,25 +3948,21 @@
             this.rewriteTypeVars = rewriteTypeVars;
         }
 
-        Type rewrite(Type t) {
-            ListBuffer<Type> from = new ListBuffer<Type>();
-            ListBuffer<Type> to = new ListBuffer<Type>();
-            adaptSelf(t, from, to);
+        @Override
+        public Type visitClassType(ClassType t, Void s) {
             ListBuffer<Type> rewritten = new ListBuffer<Type>();
-            List<Type> formals = from.toList();
             boolean changed = false;
-            for (Type arg : to.toList()) {
+            for (Type arg : t.allparams()) {
                 Type bound = visit(arg);
                 if (arg != bound) {
                     changed = true;
-                    bound = high ? makeExtendsWildcard(bound, (TypeVar)formals.head)
-                              : makeSuperWildcard(bound, (TypeVar)formals.head);
                 }
                 rewritten.append(bound);
-                formals = formals.tail;
             }
             if (changed)
-                return subst(t.tsym.type, from.toList(), rewritten.toList());
+                return subst(t.tsym.type,
+                        t.tsym.type.allparams(),
+                        rewritten.toList());
             else
                 return t;
         }
@@ -3927,13 +3973,22 @@
 
         @Override
         public Type visitCapturedType(CapturedType t, Void s) {
-            return visitWildcardType(t.wildcard, null);
+            Type bound = visitWildcardType(t.wildcard, null);
+            return (bound.contains(t)) ?
+                    (high ? syms.objectType : syms.botType) :
+                        bound;
         }
 
         @Override
         public Type visitTypeVar(TypeVar t, Void s) {
-            if (rewriteTypeVars)
-                return high ? t.bound : syms.botType;
+            if (rewriteTypeVars) {
+                Type bound = high ?
+                    (t.bound.contains(t) ?
+                        syms.objectType :
+                        visit(t.bound)) :
+                    syms.botType;
+                return rewriteAsWildcardType(bound, t);
+            }
             else
                 return t;
         }
@@ -3943,8 +3998,27 @@
             Type bound = high ? t.getExtendsBound() :
                                 t.getSuperBound();
             if (bound == null)
-                bound = high ? syms.objectType : syms.botType;
-            return bound;
+            bound = high ? syms.objectType : syms.botType;
+            return rewriteAsWildcardType(visit(bound), t.bound);
+        }
+
+        private Type rewriteAsWildcardType(Type bound, TypeVar formal) {
+            return high ?
+                makeExtendsWildcard(B(bound), formal) :
+                makeSuperWildcard(B(bound), formal);
+        }
+
+        Type B(Type t) {
+            while (t.tag == WILDCARD) {
+                WildcardType w = (WildcardType)t;
+                t = high ?
+                    w.getExtendsBound() :
+                    w.getSuperBound();
+                if (t == null) {
+                    t = high ? syms.objectType : syms.botType;
+                }
+            }
+            return t;
         }
     }
 
@@ -4130,4 +4204,24 @@
         public Type visitType(Type t, S s) { return t; }
     }
     // </editor-fold>
+
+
+    // <editor-fold defaultstate="collapsed" desc="Annotation support">
+
+    public RetentionPolicy getRetention(Attribute.Compound a) {
+        RetentionPolicy vis = RetentionPolicy.CLASS; // the default
+        Attribute.Compound c = a.type.tsym.attribute(syms.retentionType.tsym);
+        if (c != null) {
+            Attribute value = c.member(names.value);
+            if (value != null && value instanceof Attribute.Enum) {
+                Name levelName = ((Attribute.Enum)value).value.name;
+                if (levelName == names.SOURCE) vis = RetentionPolicy.SOURCE;
+                else if (levelName == names.CLASS) vis = RetentionPolicy.CLASS;
+                else if (levelName == names.RUNTIME) vis = RetentionPolicy.RUNTIME;
+                else ;// /* fail soft */ throw new AssertionError(levelName);
+            }
+        }
+        return vis;
+    }
+    // </editor-fold>
 }
--- a/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Tue Oct 19 16:26:29 2010 +0100
@@ -182,6 +182,7 @@
             if (!method.type.isErroneous())
                 buf.append(new Pair<MethodSymbol,Attribute>
                            ((MethodSymbol)method, value));
+            t.type = result;
         }
         return new Attribute.Compound(a.type, buf.toList());
     }
@@ -234,6 +235,7 @@
                                                l.head,
                                                env));
             }
+            na.type = expected;
             return new Attribute.
                 Array(expected, buf.toArray(new Attribute[buf.length()]));
         }
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue Oct 19 16:26:29 2010 +0100
@@ -126,11 +126,11 @@
         lambdaInferenceDiags = options.get("lambdaInferenceDiags") == null ||
                 !options.get("lambdaInferenceDiags").equals("false");
         sourceName = source.name;
-        relax = (options.get("-retrofit") != null ||
-                 options.get("-relax") != null);
-        useBeforeDeclarationWarning = options.get("useBeforeDeclarationWarning") != null;
-        enableSunApiLintControl = options.get("enableSunApiLintControl") != null;
-        identifyLambdaCandidate = options.get("identifyLambdaCandidate") != null &&
+        relax = (options.isSet("-retrofit") ||
+                 options.isSet("-relax"));
+        useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
+        enableSunApiLintControl = options.isSet("enableSunApiLintControl");
+        identifyLambdaCandidate = options.isSet("identifyLambdaCandidate") &&
                 options.get("identifyLambdaCandidate").equals("true") ; //default disabled
     }
 
@@ -368,6 +368,12 @@
             attribExpr(expr, env);
         } catch (BreakAttr b) {
             return b.env;
+        } catch (AssertionError ae) {
+            if (ae.getCause() instanceof BreakAttr) {
+                return ((BreakAttr)(ae.getCause())).env;
+            } else {
+                throw ae;
+            }
         } finally {
             breakTree = null;
             log.useSource(prev);
@@ -382,6 +388,12 @@
             attribStat(stmt, env);
         } catch (BreakAttr b) {
             return b.env;
+        } catch (AssertionError ae) {
+            if (ae.getCause() instanceof BreakAttr) {
+                return ((BreakAttr)(ae.getCause())).env;
+            } else {
+                throw ae;
+            }
         } finally {
             breakTree = null;
             log.useSource(prev);
@@ -623,6 +635,8 @@
                    boolean classExpected,
                    boolean interfaceExpected,
                    boolean checkExtensible) {
+        if (t.isErroneous())
+            return t;
         if (t.tag == TYPEVAR && !classExpected && !interfaceExpected) {
             // check that type variable is already visible
             if (t.getUpperBound() == null) {
@@ -728,24 +742,34 @@
 
             // Check that type parameters are well-formed.
             chk.validate(tree.typarams, localEnv);
-            if ((owner.flags() & ANNOTATION) != 0 &&
-                tree.typarams.nonEmpty())
-                log.error(tree.typarams.head.pos(),
-                          "intf.annotation.members.cant.have.type.params");
 
             // Check that result type is well-formed.
             chk.validate(tree.restype, localEnv);
-            if ((owner.flags() & ANNOTATION) != 0)
+            
+            // annotation method checks
+            if ((owner.flags() & ANNOTATION) != 0) {
+                // annotation method cannot have throws clause
+                if (tree.thrown.nonEmpty()) {
+                    log.error(tree.thrown.head.pos(),
+                            "throws.not.allowed.in.intf.annotation");
+                }
+                // annotation method cannot declare type-parameters
+                if (tree.typarams.nonEmpty()) {
+                    log.error(tree.typarams.head.pos(),
+                            "intf.annotation.members.cant.have.type.params");
+                }
+                // validate annotation method's return type (could be an annotation type)
                 chk.validateAnnotationType(tree.restype);
-
-            if ((owner.flags() & ANNOTATION) != 0)
+                // ensure that annotation method does not clash with members of Object/Annotation
                 chk.validateAnnotationMethod(tree.pos(), m);
 
-            // Check that all exceptions mentioned in the throws clause extend
-            // java.lang.Throwable.
-            if ((owner.flags() & ANNOTATION) != 0 && tree.thrown.nonEmpty())
-                log.error(tree.thrown.head.pos(),
-                          "throws.not.allowed.in.intf.annotation");
+                if (tree.defaultValue != null) {
+                    // if default value is an annotation, check it is a well-formed
+                    // annotation value (e.g. no duplicate values, no missing values, etc.)
+                    chk.validateAnnotationTree(tree.defaultValue);
+                }
+            }
+
             for (List<JCExpression> l = tree.thrown; l.nonEmpty(); l = l.tail)
                 chk.checkType(l.head.pos(), localEnv, l.head.type, syms.throwableType);
 
@@ -1230,7 +1254,10 @@
     }
 
     public void visitExec(JCExpressionStatement tree) {
-        attribExpr(tree.expr, env);
+        //a fresh environment is required for 292 inference to work properly ---
+        //see Infer.instantiatePolymorphicSignatureInstance()
+        Env<AttrContext> localEnv = env.dup(tree);
+        attribExpr(tree.expr, localEnv);
         result = null;
     }
 
@@ -1498,7 +1525,8 @@
 
             // Compute the result type.
             Type restype = mtype.getReturnType();
-            assert restype.tag != WILDCARD : mtype;
+            if (restype.tag == WILDCARD)
+                throw new AssertionError(mtype);
 
             // as a special case, array.clone() has a result that is
             // the same as static type of the array being cloned
@@ -1522,24 +1550,22 @@
                               restype.tsym);
             }
 
-            // as a special case, MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
-            // has type <T>, and T can be a primitive type.
-            if (tree.meth.getTag() == JCTree.SELECT && !typeargtypes.isEmpty()) {
-              JCFieldAccess mfield = (JCFieldAccess) tree.meth;
-              if ((mfield.selected.type.tsym != null &&
-                   (mfield.selected.type.tsym.flags() & POLYMORPHIC_SIGNATURE) != 0)
-                  ||
-                  (mfield.sym != null &&
-                   (mfield.sym.flags() & POLYMORPHIC_SIGNATURE) != 0)) {
-                  assert types.isSameType(restype, typeargtypes.head) : mtype;
-                  assert mfield.selected.type == syms.methodHandleType
-                      || mfield.selected.type == syms.invokeDynamicType;
-                  typeargtypesNonRefOK = true;
-              }
+            // Special case logic for JSR 292 types.
+            if (rs.allowTransitionalJSR292 &&
+                    tree.meth.getTag() == JCTree.SELECT &&
+                    !typeargtypes.isEmpty()) {
+                JCFieldAccess mfield = (JCFieldAccess) tree.meth;
+                // MethodHandle.<T>invoke(abc) and InvokeDynamic.<T>foo(abc)
+                // has type <T>, and T can be a primitive type.
+                if (mfield.sym != null &&
+                        mfield.sym.isPolymorphicSignatureInstance())
+                    typeargtypesNonRefOK = true;
             }
 
-            if (!typeargtypesNonRefOK) {
-                chk.checkParameterTypes(tree.typeargs, typeargtypes, TreeInfo.symbol(tree.meth).type.getTypeArguments());
+            if (!(rs.allowTransitionalJSR292 && typeargtypesNonRefOK)) {
+                chk.checkParameterTypes(tree.typeargs,
+                        typeargtypes,
+                        TreeInfo.symbol(tree.meth).type.getTypeArguments());
             }
 
             // Check that value of resulting type is admissible in the
@@ -1651,7 +1677,7 @@
         List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
 
         if (TreeInfo.isDiamond(tree)) {
-            clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes, true);
+            clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes);
             clazz.type = clazztype;
         }
 
@@ -1691,13 +1717,15 @@
                 localEnv.info.varArgs = false;
                 tree.constructor = rs.resolveConstructor(
                     tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
-                tree.constructorType = checkMethod(clazztype,
-                                                tree.constructor,
-                                                localEnv,
-                                                tree.args,
-                                                argtypes,
-                                                typeargtypes,
-                                                localEnv.info.varArgs);
+                tree.constructorType = tree.constructor.type.isErroneous() ?
+                    syms.errType :
+                    checkMethod(clazztype,
+                        tree.constructor,
+                        localEnv,
+                        tree.args,
+                        argtypes,
+                        typeargtypes,
+                        localEnv.info.varArgs);
                 if (localEnv.info.varArgs)
                     assert tree.constructorType.isErroneous() || tree.varargsElement != null;
             }
@@ -1796,8 +1824,7 @@
                         Type clazztype,
                         Pair<Scope, Scope> mapping,
                         List<Type> argtypes,
-                        List<Type> typeargtypes,
-                        boolean reportErrors) {
+                        List<Type> typeargtypes) {
         if (clazztype.isErroneous() || mapping == erroneousMapping) {
             //if the type of the instance creation expression is erroneous,
             //or something prevented us to form a valid mapping, return the
@@ -1835,7 +1862,7 @@
                         env,
                         clazztype.tsym.type,
                         argtypes,
-                        typeargtypes, reportErrors);
+                        typeargtypes);
             } finally {
                 ((ClassSymbol) clazztype.tsym).members_field = mapping.fst;
             }
@@ -1864,42 +1891,37 @@
                         Warner.noWarnings);
             } catch (Infer.InferenceException ex) {
                 //an error occurred while inferring uninstantiated type-variables
-                //we need to optionally report an error
-                if (reportErrors) {
-                    log.error(tree.clazz.pos(),
+                log.error(tree.clazz.pos(),
+                        "cant.apply.diamond.1",
+                        diags.fragment("diamond", clazztype.tsym),
+                        ex.diagnostic);
+            }
+        }
+        clazztype = chk.checkClassType(tree.clazz.pos(),
+                clazztype,
+                true);
+        if (clazztype.tag == CLASS) {
+            List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
+            if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
+                //one or more types inferred in the previous steps is either a
+                //captured type or an intersection type --- we need to report an error.
+                String subkey = invalidDiamondArgs.size() > 1 ?
+                    "diamond.invalid.args" :
+                    "diamond.invalid.arg";
+                //The error message is of the kind:
+                //
+                //cannot infer type arguments for {clazztype}<>;
+                //reason: {subkey}
+                //
+                //where subkey is a fragment of the kind:
+                //
+                //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
+                log.error(tree.clazz.pos(),
                             "cant.apply.diamond.1",
                             diags.fragment("diamond", clazztype.tsym),
-                            ex.diagnostic);
-                }
-            }
-        }
-        if (reportErrors) {
-            clazztype = chk.checkClassType(tree.clazz.pos(),
-                    clazztype,
-                    true);
-            if (clazztype.tag == CLASS) {
-                List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
-                if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
-                    //one or more types inferred in the previous steps is either a
-                    //captured type or an intersection type --- we need to report an error.
-                    String subkey = invalidDiamondArgs.size() > 1 ?
-                        "diamond.invalid.args" :
-                        "diamond.invalid.arg";
-                    //The error message is of the kind:
-                    //
-                    //cannot infer type arguments for {clazztype}<>;
-                    //reason: {subkey}
-                    //
-                    //where subkey is a fragment of the kind:
-                    //
-                    //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
-                    log.error(tree.clazz.pos(),
-                                "cant.apply.diamond.1",
-                                diags.fragment("diamond", clazztype.tsym),
-                                diags.fragment(subkey,
-                                               invalidDiamondArgs,
-                                               diags.fragment("diamond", clazztype.tsym)));
-                }
+                            diags.fragment(subkey,
+                                           invalidDiamondArgs,
+                                           diags.fragment("diamond", clazztype.tsym)));
             }
         }
         return clazztype;
@@ -2209,11 +2231,11 @@
         Type resType = null;
         ListBuffer<Type> argtypes = ListBuffer.lb();
 
-        boolean prevLogEnabled = log.isEnabled();
+        boolean prevDeferDiags = log.deferDiagnostics;
         try {
             //disable the log -- we need to do this in order to avoid
             //spurious error messages from this partial attribution sweep
-            log.setEnabled(false);
+            log.deferDiagnostics = true;
             //attribute lambda parameters
             attribStats(that.params, localEnv);
             for (JCTree arg : that.params) {
@@ -2237,7 +2259,7 @@
             }
         }
         finally {
-            log.setEnabled(prevLogEnabled);
+            log.deferDiagnostics =  prevDeferDiags;
         }
 
         //there are two causes that disable inference of lambda return type:
@@ -2261,9 +2283,10 @@
         //if one or more 'partial' types were accessed during this first attribution
         //pass, then thrown types are left uninferred (as e.g. calling an unknown
         //method on an unknown type might raise unknown exception types).
-        if (log.suppressedDiagnostics.containsKey(JCDiagnostic.Kind.ERROR)) {
+        List<JCDiagnostic> deferredErrors = log.getDeferredDiags(JCDiagnostic.Kind.ERROR);
+        if (deferredErrors.nonEmpty()) {
             ListBuffer<Name> uninferredTypeNames = ListBuffer.lb();
-            for (JCDiagnostic diag : log.suppressedDiagnostics.get(JCDiagnostic.Kind.ERROR)) {
+            for (JCDiagnostic diag : deferredErrors) {
                 searchUninferredTypes(diag, uninferredTypeNames);
             }
             if (uninferredTypeNames.nonEmpty() && lambdaInferenceDiags) {
@@ -2508,10 +2531,12 @@
 
     public void visitTypeCast(JCTypeCast tree) {
         Type clazztype = attribType(tree.clazz, env);
-        chk.validate(tree.clazz, env);
+		chk.validate(tree.clazz, env, false);
+        //a fresh environment is required for 292 inference to work properly ---
+        //see Infer.instantiatePolymorphicSignatureInstance()
         Env<AttrContext> localEnv = env.dup(tree);
         Type exprtype = attribExpr(tree.expr, localEnv, Infer.anyPoly);
-        Type owntype = chk.checkCastable(tree.expr.pos(), localEnv, exprtype, clazztype);
+        Type owntype = chk.checkCastable(tree.expr.pos(), env, exprtype, clazztype);
         if (exprtype.constValue() != null)
             owntype = cfolder.coerce(exprtype, owntype);
         result = check(tree, capture(owntype), VAL, pkind, pt);
@@ -2522,7 +2547,7 @@
             tree.expr.pos(), attribExpr(tree.expr, env));
         Type clazztype = chk.checkReifiableReferenceType(
             tree.clazz.pos(), attribType(tree.clazz, env));
-        chk.validate(tree.clazz, env);
+        chk.validate(tree.clazz, env, false);
         chk.checkCastable(tree.expr.pos(), env, exprtype, clazztype);
         result = check(tree, syms.booleanType, VAL, pkind, pt);
     }
@@ -2638,7 +2663,8 @@
         switch (tree.mode) {
             case INVOKE:
                 JCMethodInvocation apply = (JCMethodInvocation) expr;
-                attribExpr(apply, localEnv);
+                Type mtype = attribExpr(apply, localEnv);
+                apply.type = mtype;
                 JCTree base = TreeInfo.getSelector(apply);
                 if (TreeInfo.isStaticSelector(base, names)) {
                     chk.validate(base, localEnv);
@@ -3451,7 +3477,6 @@
                 if (tree.bounds.tail.nonEmpty()) {
                     log.error(tree.bounds.tail.head.pos(),
                               "type.var.may.not.be.followed.by.other.bounds");
-                    log.unrecoverableError = true;
                     tree.bounds = List.of(tree.bounds.head);
                     a.bound = bs.head;
                 }
@@ -3795,4 +3820,123 @@
             super.visitMethodDef(tree);
         }
     };
+
+    // <editor-fold desc="post-attribution visitor">
+
+    /**
+     * Handle missing types/symbols in an AST. This routine is useful when
+     * the compiler has encountered some errors (which might have ended up
+     * terminating attribution abruptly); if the compiler is used in fail-over
+     * mode (e.g. by an IDE) and the AST contains semantic errors, this routine
+     * prevents NPE to be progagated during subsequent compilation steps.
+     */
+    public void postAttr(Env<AttrContext> env) {
+        new PostAttrAnalyzer().scan(env.tree);
+    }
+
+    class PostAttrAnalyzer extends TreeScanner {
+
+        private void initTypeIfNeeded(JCTree that) {
+            if (that.type == null) {
+                that.type = syms.unknownType;
+            }
+        }
+
+        @Override
+        public void scan(JCTree tree) {
+            if (tree == null) return;
+            if (tree instanceof JCExpression) {
+                initTypeIfNeeded(tree);
+            }
+            super.scan(tree);
+        }
+
+        @Override
+        public void visitIdent(JCIdent that) {
+            if (that.sym == null) {
+                that.sym = syms.unknownSymbol;
+            }
+        }
+
+        @Override
+        public void visitSelect(JCFieldAccess that) {
+            if (that.sym == null) {
+                that.sym = syms.unknownSymbol;
+            }
+            super.visitSelect(that);
+        }
+
+        @Override
+        public void visitClassDef(JCClassDecl that) {
+            initTypeIfNeeded(that);
+            if (that.sym == null) {
+                that.sym = new ClassSymbol(0, that.name, that.type, syms.noSymbol);
+            }
+            super.visitClassDef(that);
+        }
+
+        @Override
+        public void visitMethodDef(JCMethodDecl that) {
+            initTypeIfNeeded(that);
+            if (that.sym == null) {
+                that.sym = new MethodSymbol(0, that.name, that.type, syms.noSymbol);
+            }
+            super.visitMethodDef(that);
+        }
+
+        @Override
+        public void visitVarDef(JCVariableDecl that) {
+            initTypeIfNeeded(that);
+            if (that.sym == null) {
+                that.sym = new VarSymbol(0, that.name, that.type, syms.noSymbol);
+                that.sym.adr = 0;
+            }
+            super.visitVarDef(that);
+        }
+
+        @Override
+        public void visitNewClass(JCNewClass that) {
+            if (that.constructor == null) {
+                that.constructor = new MethodSymbol(0, names.init, syms.unknownType, syms.noSymbol);
+            }
+            if (that.constructorType == null) {
+                that.constructorType = syms.unknownType;
+            }
+            super.visitNewClass(that);
+        }
+
+        @Override
+        public void visitBinary(JCBinary that) {
+            if (that.operator == null)
+                that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
+            super.visitBinary(that);
+        }
+
+        @Override
+        public void visitUnary(JCUnary that) {
+            if (that.operator == null)
+                that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
+            super.visitUnary(that);
+        }
+
+        @Override
+        public void visitLambda(JCLambda that) {
+            super.visitLambda(that);
+            if (that.targetType == null) {
+                that.targetType = syms.unknownType;
+            }
+            if (that.sym == null) {
+                that.sym = new MethodSymbol(0, names.lambda, syms.unknownType, syms.noSymbol);
+            }
+        }
+
+        @Override
+        public void visitReference(JCMemberReference that) {
+            super.visitReference(that);
+            if (that.sym == null) {
+                that.sym = new MethodSymbol(0, names.lambda, syms.unknownType, syms.noSymbol);
+            }
+        }
+    }
+    // </editor-fold>
 }
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Oct 19 16:26:29 2010 +0100
@@ -45,6 +45,8 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.TypeTags.*;
 
+import static com.sun.tools.javac.main.OptionName.*;
+
 /** Type checking helper class for the attribution phase.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -59,6 +61,7 @@
     private final Names names;
     private final Log log;
     private final Symtab syms;
+    private final Enter enter;
     private final Infer infer;
     private final Types types;
     private final JCDiagnostic.Factory diags;
@@ -85,6 +88,7 @@
         names = Names.instance(context);
         log = Log.instance(context);
         syms = Symtab.instance(context);
+        enter = Enter.instance(context);
         infer = Infer.instance(context);
         this.types = Types.instance(context);
         diags = JCDiagnostic.Factory.instance(context);
@@ -97,10 +101,10 @@
         allowAnnotations = source.allowAnnotations();
         allowCovariantReturns = source.allowCovariantReturns();
         allowDefenderMethods = source.allowDefenderMethods();
-        complexInference = options.get("-complexinference") != null;
-        skipAnnotations = options.get("skipAnnotations") != null;
-        warnOnSyntheticConflicts = options.get("warnOnSyntheticConflicts") != null;
-        suppressAbortOnBadClassFile = options.get("suppressAbortOnBadClassFile") != null;
+        complexInference = options.isSet(COMPLEXINFERENCE);
+        skipAnnotations = options.isSet("skipAnnotations");
+        warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts");
+        suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile");
 
         Target target = Target.instance(context);
         syntheticNameChar = target.syntheticNameChar();
@@ -334,7 +338,7 @@
             for (Scope.Entry e = s.next.lookup(c.name);
                  e.scope != null && e.sym.owner == c.owner;
                  e = e.next()) {
-                if (e.sym.kind == TYP &&
+                if (e.sym.kind == TYP && e.sym.type.tag != TYPEVAR &&
                     (e.sym.owner.kind & (VAR | MTH)) != 0 &&
                     c.name != names.error) {
                     duplicateError(pos, e.sym);
@@ -988,33 +992,15 @@
      *
      *  and we can't make sure that the bound is already attributed because
      *  of possible cycles.
-     */
-    private Validator validator = new Validator();
-
-    /** Visitor method: Validate a type expression, if it is not null, catching
+     *
+     * Visitor method: Validate a type expression, if it is not null, catching
      *  and reporting any completion failures.
      */
     void validate(JCTree tree, Env<AttrContext> env) {
-        try {
-            if (tree != null) {
-                validator.env = env;
-                tree.accept(validator);
-                checkRaw(tree, env);
-            }
-        } catch (CompletionFailure ex) {
-            completionError(tree.pos(), ex);
-        }
+        validate(tree, env, true);
     }
-    //where
-    void checkRaw(JCTree tree, Env<AttrContext> env) {
-        if (lint.isEnabled(Lint.LintCategory.RAW) &&
-            tree.type.tag == CLASS &&
-            !TreeInfo.isDiamond(tree) &&
-            !env.enclClass.name.isEmpty() &&  //anonymous or intersection
-            tree.type.isRaw()) {
-            log.warning(Lint.LintCategory.RAW,
-                    tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
-        }
+    void validate(JCTree tree, Env<AttrContext> env, boolean checkRaw) {
+        new Validator(env).validateTree(tree, checkRaw, true);
     }
 
     /** Visitor method: Validate a list of type expressions.
@@ -1028,12 +1014,19 @@
      */
     class Validator extends JCTree.Visitor {
 
+        boolean isOuter;
+        Env<AttrContext> env;
+
+        Validator(Env<AttrContext> env) {
+            this.env = env;
+        }
+
         @Override
         public void visitTypeArray(JCArrayTypeTree tree) {
             boolean prevAllowsThrowsTyparams = env.info.allowsDisjointTypes;
             try {
                 env.info.allowsDisjointTypes = false;
-                validate(tree.elemtype, env);
+                tree.elemtype.accept(this);
             }
             finally {
                 env.info.allowsDisjointTypes = prevAllowsThrowsTyparams;
@@ -1049,6 +1042,8 @@
                 List<Type> forms = tree.type.tsym.type.getTypeArguments();
                 ListBuffer<Type> tvars_buf = new ListBuffer<Type>();
 
+                boolean is_java_lang_Class = tree.type.tsym.flatName() == names.java_lang_Class;
+
                 // For matching pairs of actual argument types `a' and
                 // formal type parameters with declared bound `b' ...
                 while (args.nonEmpty() && forms.nonEmpty()) {
@@ -1056,7 +1051,9 @@
                     try {
                         env.info.allowsDisjointTypes =
                                 (forms.head.tsym.flags() & THROWS) != 0;
-                        validate(args.head, env);
+                        validateTree(args.head,
+                            !(isOuter && is_java_lang_Class),
+                            false);
                     }
                     finally {
                         env.info.allowsDisjointTypes = prevAllowsThrowsTyparams;
@@ -1116,7 +1113,7 @@
 
         @Override
         public void visitTypeParameter(JCTypeParameter tree) {
-            validate(tree.bounds, env);
+            validateTrees(tree.bounds, true, isOuter);
             checkClassBounds(tree.pos(), tree.type);
         }
 
@@ -1131,7 +1128,7 @@
         @Override
         public void visitWildcard(JCWildcard tree) {
             if (tree.inner != null)
-                validate(tree.inner, env);
+                validateTree(tree.inner, true, isOuter);
         }
 
         @Override
@@ -1177,7 +1174,34 @@
         public void visitTree(JCTree tree) {
         }
 
-        Env<AttrContext> env;
+        public void validateTree(JCTree tree, boolean checkRaw, boolean isOuter) {
+            try {
+                if (tree != null) {
+                    this.isOuter = isOuter;
+                    tree.accept(this);
+                    if (checkRaw)
+                        checkRaw(tree, env);
+                }
+            } catch (CompletionFailure ex) {
+                completionError(tree.pos(), ex);
+            }
+        }
+
+        public void validateTrees(List<? extends JCTree> trees, boolean checkRaw, boolean isOuter) {
+            for (List<? extends JCTree> l = trees; l.nonEmpty(); l = l.tail)
+                validateTree(l.head, checkRaw, isOuter);
+        }
+
+        void checkRaw(JCTree tree, Env<AttrContext> env) {
+            if (lint.isEnabled(Lint.LintCategory.RAW) &&
+                tree.type.tag == CLASS &&
+                !TreeInfo.isDiamond(tree) &&
+                !env.enclClass.name.isEmpty() &&  //anonymous or intersection
+                tree.type.isRaw()) {
+                log.warning(Lint.LintCategory.RAW,
+                        tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type);
+            }
+        }
     }
 
 /* *************************************************************************
@@ -1862,6 +1886,113 @@
             return undef;
         }
 
+    void checkNonCyclicDecl(JCClassDecl tree) {
+        CycleChecker cc = new CycleChecker();
+        cc.scan(tree);
+        if (!cc.errorFound && !cc.partialCheck) {
+            tree.sym.flags_field |= ACYCLIC;
+        }
+    }
+
+    class CycleChecker extends TreeScanner {
+
+        List<Symbol> seenClasses = List.nil();
+        boolean errorFound = false;
+        boolean partialCheck = false;
+
+        private void checkSymbol(DiagnosticPosition pos, Symbol sym) {
+            if (sym != null && sym.kind == TYP) {
+                Env<AttrContext> classEnv = enter.getEnv((TypeSymbol)sym);
+                if (classEnv != null) {
+                    DiagnosticSource prevSource = log.currentSource();
+                    try {
+                        log.useSource(classEnv.toplevel.sourcefile);
+                        scan(classEnv.tree);
+                    }
+                    finally {
+                        log.useSource(prevSource.getFile());
+                    }
+                } else if (sym.kind == TYP) {
+                    checkClass(pos, sym, List.<JCTree>nil());
+                }
+            } else {
+                //not completed yet
+                partialCheck = true;
+            }
+        }
+
+        @Override
+        public void visitSelect(JCFieldAccess tree) {
+            super.visitSelect(tree);
+            checkSymbol(tree.pos(), tree.sym);
+        }
+
+        @Override
+        public void visitIdent(JCIdent tree) {
+            checkSymbol(tree.pos(), tree.sym);
+        }
+
+        @Override
+        public void visitTypeApply(JCTypeApply tree) {
+            scan(tree.clazz);
+        }
+
+        @Override
+        public void visitTypeArray(JCArrayTypeTree tree) {
+            scan(tree.elemtype);
+        }
+
+        @Override
+        public void visitClassDef(JCClassDecl tree) {
+            List<JCTree> supertypes = List.nil();
+            if (tree.getExtendsClause() != null) {
+                supertypes = supertypes.prepend(tree.getExtendsClause());
+            }
+            if (tree.getImplementsClause() != null) {
+                for (JCTree intf : tree.getImplementsClause()) {
+                    supertypes = supertypes.prepend(intf);
+                }
+            }
+            checkClass(tree.pos(), tree.sym, supertypes);
+        }
+
+        void checkClass(DiagnosticPosition pos, Symbol c, List<JCTree> supertypes) {
+            if ((c.flags_field & ACYCLIC) != 0)
+                return;
+            if (seenClasses.contains(c)) {
+                errorFound = true;
+                noteCyclic(pos, (ClassSymbol)c);
+            } else if (!c.type.isErroneous()) {
+                try {
+                    seenClasses = seenClasses.prepend(c);
+                    if (c.type.tag == CLASS) {
+                        if (supertypes.nonEmpty()) {
+                            scan(supertypes);
+                        }
+                        else {
+                            ClassType ct = (ClassType)c.type;
+                            if (ct.supertype_field == null ||
+                                    ct.interfaces_field == null) {
+                                //not completed yet
+                                partialCheck = true;
+                                return;
+                            }
+                            checkSymbol(pos, ct.supertype_field.tsym);
+                            for (Type intf : ct.interfaces_field) {
+                                checkSymbol(pos, intf.tsym);
+                            }
+                        }
+                        if (c.owner.kind == TYP) {
+                            checkSymbol(pos, c.owner);
+                        }
+                    }
+                } finally {
+                    seenClasses = seenClasses.tail;
+                }
+            }
+        }
+    }
+
     /** Check for cyclic references. Issue an error if the
      *  symbol of the type referred to has a LOCKED flag set.
      *
@@ -2085,6 +2216,20 @@
  * Check annotations
  **************************************************************************/
 
+    /**
+     * Recursively validate annotations values
+     */
+    void validateAnnotationTree(JCTree tree) {
+        class AnnotationValidator extends TreeScanner {
+            @Override
+            public void visitAnnotation(JCAnnotation tree) {
+                super.visitAnnotation(tree);
+                validateAnnotation(tree);
+            }
+        }
+        tree.accept(new AnnotationValidator());
+    }
+
     /** Annotation types are restricted to primitives, String, an
      *  enum, an annotation, Class, Class<?>, Class<? extends
      *  Anything>, arrays of the preceding.
@@ -2148,7 +2293,7 @@
     /** Check an annotation of a symbol.
      */
     public void validateAnnotation(JCAnnotation a, Symbol s) {
-        validateAnnotation(a);
+        validateAnnotationTree(a);
 
         if (!annotationApplicable(a, s))
             log.error(a.pos(), "annotation.type.not.applicable");
@@ -2162,7 +2307,7 @@
     public void validateTypeAnnotation(JCTypeAnnotation a, boolean isTypeParameter) {
         if (a.type == null)
             throw new AssertionError("annotation tree hasn't been attributed yet: " + a);
-        validateAnnotation(a);
+        validateAnnotationTree(a);
 
         if (!isTypeAnnotation(a, isTypeParameter))
             log.error(a.pos(), "annotation.type.not.applicable");
@@ -2259,8 +2404,12 @@
     public void validateAnnotation(JCAnnotation a) {
         if (a.type.isErroneous()) return;
 
-        // collect an inventory of the members
-        Set<MethodSymbol> members = new HashSet<MethodSymbol>();
+        // collect an inventory of the members (sorted alphabetically)
+        Set<MethodSymbol> members = new TreeSet<MethodSymbol>(new Comparator<Symbol>() {
+            public int compare(Symbol t, Symbol t1) {
+                return t.name.compareTo(t1.name);
+            }
+        });
         for (Scope.Entry e = a.annotationType.type.tsym.members().elems;
              e != null;
              e = e.sibling)
@@ -2276,15 +2425,21 @@
             if (!members.remove(m))
                 log.error(assign.lhs.pos(), "duplicate.annotation.member.value",
                           m.name, a.type);
-            if (assign.rhs.getTag() == ANNOTATION)
-                validateAnnotation((JCAnnotation)assign.rhs);
         }
 
         // all the remaining ones better have default values
-        for (MethodSymbol m : members)
-            if (m.defaultValue == null && !m.type.isErroneous())
-                log.error(a.pos(), "annotation.missing.default.value",
-                          a.type, m.name);
+        ListBuffer<Name> missingDefaults = ListBuffer.lb();
+        for (MethodSymbol m : members) {
+            if (m.defaultValue == null && !m.type.isErroneous()) {
+                missingDefaults.append(m.name);
+            }
+        }
+        if (missingDefaults.nonEmpty()) {
+            String key = (missingDefaults.size() > 1)
+                    ? "annotation.missing.default.value.1"
+                    : "annotation.missing.default.value";
+            log.error(a.pos(), key, a.type, missingDefaults);
+        }
 
         // special case: java.lang.annotation.Target must not have
         // repeated values in its value member
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java	Tue Oct 19 16:26:29 2010 +0100
@@ -38,6 +38,7 @@
 
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.main.RecognizedOptions.PkgInfo;
 import com.sun.tools.javac.tree.JCTree.*;
 
 import static com.sun.tools.javac.code.Flags.*;
@@ -93,6 +94,7 @@
 
     Log log;
     Symtab syms;
+    Scope.ScopeCounter scopeCounter;
     Check chk;
     TreeMaker make;
     ClassReader reader;
@@ -102,6 +104,7 @@
     Lint lint;
     Names names;
     JavaFileManager fileManager;
+    PkgInfo pkginfoOpt;
 
     private final Todo todo;
 
@@ -119,6 +122,7 @@
         reader = ClassReader.instance(context);
         make = TreeMaker.instance(context);
         syms = Symtab.instance(context);
+        scopeCounter = Scope.ScopeCounter.instance(context);
         chk = Check.instance(context);
         memberEnter = MemberEnter.instance(context);
         types = Types.instance(context);
@@ -132,6 +136,9 @@
         predefClassDef.sym = syms.predefClass;
         todo = Todo.instance(context);
         fileManager = context.get(JavaFileManager.class);
+
+        Options options = Options.instance(context);
+        pkginfoOpt = PkgInfo.get(options);
     }
 
     /** A hashtable mapping classes and packages to the environments current
@@ -184,7 +191,7 @@
      */
     public Env<AttrContext> classEnv(JCClassDecl tree, Env<AttrContext> env) {
         Env<AttrContext> localEnv =
-            env.dup(tree, env.info.dup(new Scope(tree.sym)));
+            env.dup(tree, env.info.dup(new Scope.ClassScope(tree.sym, scopeCounter)));
         localEnv.enclClass = tree;
         localEnv.outer = env;
         localEnv.info.isSelfCall = false;
@@ -278,7 +285,7 @@
                                                              JavaFileObject.Kind.SOURCE);
         if (tree.pid != null) {
             tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid));
-            if (tree.packageAnnotations.nonEmpty()) {
+            if (tree.packageAnnotations.nonEmpty() || pkginfoOpt == PkgInfo.ALWAYS) {
                 if (isPkgInfo) {
                     addEnv = true;
                 } else {
@@ -320,7 +327,7 @@
             c.flatname = names.fromString(tree.packge + "." + name);
             c.sourcefile = tree.sourcefile;
             c.completer = null;
-            c.members_field = new Scope(c);
+            c.members_field = new Scope.ClassScope(c, scopeCounter);
             tree.packge.package_info = c;
         }
         classEnter(tree.defs, topEnv);
@@ -388,7 +395,7 @@
         c.completer = memberEnter;
         c.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, c, tree);
         c.sourcefile = env.toplevel.sourcefile;
-        c.members_field = new Scope(c);
+        c.members_field = new Scope.ClassScope(c, scopeCounter);
 
         setEnclosingType(c, owner);
 
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Oct 19 16:26:29 2010 +0100
@@ -420,7 +420,9 @@
         tree = TreeInfo.skipParens(tree);
         if (tree.getTag() == JCTree.IDENT || tree.getTag() == JCTree.SELECT) {
             Symbol sym = TreeInfo.symbol(tree);
-            letInit(tree.pos(), (VarSymbol)sym);
+            if (sym.kind == VAR) {
+                letInit(tree.pos(), (VarSymbol)sym);
+            }
         }
     }
 
@@ -502,12 +504,13 @@
 
     /** Split (duplicate) inits/uninits into WhenTrue/WhenFalse sets
      */
-    void split() {
+    void split(boolean setToNull) {
         initsWhenFalse = inits.dup();
         uninitsWhenFalse = uninits.dup();
         initsWhenTrue = inits;
         uninitsWhenTrue = uninits;
-        inits = uninits = null;
+        if (setToNull)
+            inits = uninits = null;
     }
 
     /** Merge (intersect) inits/uninits from WhenTrue/WhenFalse sets.
@@ -589,9 +592,11 @@
             uninitsWhenTrue = uninits;
         } else {
             scan(tree);
-            if (inits != null) split();
+            if (inits != null)
+                split(tree.type != syms.unknownType);
         }
-        inits = uninits = null;
+        if (tree.type != syms.unknownType)
+            inits = uninits = null;
     }
 
     /* ------------ Visitor methods for various sorts of trees -------------*/
@@ -1032,7 +1037,7 @@
                 List.of(resource.type);
             for (Type sup : closeableSupertypes) {
                 if (types.asSuper(sup, syms.autoCloseableType.tsym) != null) {
-                    Symbol closeMethod = rs.resolveInternalMethod(tree,
+                    Symbol closeMethod = rs.resolveQualifiedMethod(tree,
                             attrEnv,
                             sup,
                             names.close,
@@ -1074,21 +1079,23 @@
             List<Type> ctypes = List.nil();
             List<Type> rethrownTypes = chk.diff(thrownInTry, caughtInTry);
             for (JCExpression ct : subClauses) {
-                Type exc = types.erasure(ct.type);
-                ctypes = ctypes.append(exc);
-                if (types.isSameType(exc, syms.objectType))
-                    continue;
-                if (chk.subset(exc, caughtInTry)) {
-                    log.error(l.head.pos(),
-                              "except.already.caught", exc);
-                } else if (!chk.isUnchecked(l.head.pos(), exc) &&
-                           exc.tsym != syms.throwableType.tsym &&
-                           exc.tsym != syms.exceptionType.tsym &&
-                           !chk.intersects(exc, thrownInTry)) {
-                    log.error(l.head.pos(),
-                              "except.never.thrown.in.try", exc);
-                }
-                caughtInTry = chk.incl(exc, caughtInTry);
+				if (ct.type != syms.unknownType) {
+		            Type exc = types.erasure(ct.type);
+		            ctypes = ctypes.append(exc);
+		            if (types.isSameType(exc, syms.objectType))
+		                continue;
+		            if (chk.subset(exc, caughtInTry)) {
+		                log.error(l.head.pos(),
+		                          "except.already.caught", exc);
+		            } else if (!chk.isUnchecked(l.head.pos(), exc) &&
+		                       exc.tsym != syms.throwableType.tsym &&
+		                       exc.tsym != syms.exceptionType.tsym &&
+		                       !chk.intersects(exc, thrownInTry)) {
+		                log.error(l.head.pos(),
+		                          "except.never.thrown.in.try", exc);
+		            }
+		            caughtInTry = chk.incl(exc, caughtInTry);
+				}
             }
             inits = initsTry.dup();
             uninits = uninitsTry.dup();
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Oct 19 16:26:29 2010 +0100
@@ -25,6 +25,8 @@
 
 package com.sun.tools.javac.comp;
 
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCTypeCast;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.code.*;
@@ -80,27 +82,31 @@
 
     }
 
-    public static class InferenceException extends RuntimeException {
+    public static class InferenceException extends Resolve.InapplicableMethodException {
         private static final long serialVersionUID = 0;
 
-        JCDiagnostic diagnostic;
-        JCDiagnostic.Factory diags;
-        List<Type> tvars;
+        public List<Type> tvars;
 
         InferenceException(JCDiagnostic.Factory diags) {
-            this.diagnostic = null;
-            this.diags = diags;
+            super(diags);
         }
 
-        InferenceException setMessage(List<Type> tvars, String key, Object... args) {
-            this.diagnostic = diags.fragment(key, args);
+        public InferenceException setTvars(List<Type> tvars) {
             this.tvars = tvars;
             return this;
         }
-
-        public JCDiagnostic getDiagnostic() {
-             return diagnostic;
-         }
+        @Override
+        InferenceException setMessage(String key) {
+            super.setMessage(key);
+            tvars = null;
+            return this;
+        }
+        @Override
+        InferenceException setMessage(String key, Object... args) {
+            super.setMessage(key, args);
+            tvars = null;
+            return this;
+        }
     }
 
     public static class NoInstanceException extends InferenceException {
@@ -142,24 +148,73 @@
     /** A mapping that returns its type argument with every UndetVar replaced
      *  by its `inst' field. Throws a NoInstanceException
      *  if this not possible because an `inst' field is null.
+     *  Note: mutually referring undertvars will be left uninstantiated
+     *  (that is, they will be replaced by the underlying type-variable).
      */
+
     Mapping getInstFun = new Mapping("getInstFun") {
             public Type apply(Type t) {
                 switch (t.tag) {
-                case UNKNOWN:
-                    throw ambiguousNoInstanceException
-                        .setMessage(List.<Type>nil(), "undetermined.type");
-                case UNDETVAR:
-                    UndetVar that = (UndetVar) t;
-                    if (that.inst == null)
+                    case UNKNOWN:
                         throw ambiguousNoInstanceException
-                            .setMessage(List.<Type>of(that.qtype), "type.variable.has.undetermined.type",
-                                        that.qtype);
-                    return apply(that.inst);
-                default:
-                    return t.map(this);
+                            .setMessage("undetermined.type");
+                    case UNDETVAR:
+                        UndetVar that = (UndetVar) t;
+                        if (that.inst == null)
+                            throw ambiguousNoInstanceException
+                                .setMessage("type.variable.has.undetermined.type",
+                                            that.qtype);
+                        return isConstraintCyclic(that) ?
+                            that.qtype :
+                            apply(that.inst);
+                        default:
+                            return t.map(this);
                 }
             }
+
+            private boolean isConstraintCyclic(UndetVar uv) {
+                Types.UnaryVisitor<Boolean> constraintScanner =
+                        new Types.UnaryVisitor<Boolean>() {
+
+                    List<Type> seen = List.nil();
+
+                    Boolean visit(List<Type> ts) {
+                        for (Type t : ts) {
+                            if (visit(t)) return true;
+                        }
+                        return false;
+                    }
+
+                    public Boolean visitType(Type t, Void ignored) {
+                        return false;
+                    }
+
+                    @Override
+                    public Boolean visitClassType(ClassType t, Void ignored) {
+                        if (t.isCompound()) {
+                            return visit(types.supertype(t)) ||
+                                    visit(types.interfaces(t));
+                        } else {
+                            return visit(t.getTypeArguments());
+                        }
+                    }
+                    @Override
+                    public Boolean visitWildcardType(WildcardType t, Void ignored) {
+                        return visit(t.type);
+                    }
+
+                    @Override
+                    public Boolean visitUndetVar(UndetVar t, Void ignored) {
+                        if (seen.contains(t)) {
+                            return true;
+                        } else {
+                            seen = seen.prepend(t);
+                            return visit(t.inst);
+                        }
+                    }
+                };
+                return constraintScanner.visit(uv);
+            }
         };
 
 /***************************************************************************
@@ -181,8 +236,8 @@
         if (that.inst == null ||
             that.inst.isErroneous())
             throw ambiguousNoInstanceException
-                .setMessage(List.<Type>of(that.qtype), "no.unique.maximal.instance.exists",
-                            that.qtype, that.hibounds);
+                .setMessage("no.unique.maximal.instance.exists",
+                            that.qtype, that.hibounds).setTvars(List.<Type>of(that.qtype));
     }
     //where
         private boolean isSubClass(Type t, final List<Type> ts) {
@@ -221,8 +276,8 @@
             }
             if (that.inst == null || that.inst.tag == ERROR)
                     throw ambiguousNoInstanceException
-                        .setMessage(List.<Type>of(that.qtype), "no.unique.minimal.instance.exists",
-                                    that.qtype, that.lobounds);
+                        .setMessage("no.unique.minimal.instance.exists",
+                                    that.qtype, that.lobounds).setTvars(List.<Type>of(that.qtype));
             // VGJ: sort of inlined maximizeInst() below.  Adding
             // bounds can cause lobounds that are above hibounds.
             if (that.hibounds.isEmpty())
@@ -262,9 +317,7 @@
             TypeVar tv = (TypeVar)uv.qtype;
             ListBuffer<Type> hibounds = new ListBuffer<Type>();
             for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS)) {
-                if (!t.containsSome(that.tvars) && t.tag != BOT) {
-                    hibounds.append(t);
-                }
+                hibounds.append(types.subst(t, that.tvars, undetvars));
             }
             List<Type> inst = that.getConstraints(tv, ConstraintKind.EQUAL);
             if (inst.nonEmpty() && inst.head.tag != BOT) {
@@ -287,8 +340,8 @@
         }
         if (!ok) {
             throw unambiguousNoInstanceException
-                .setMessage(that.tvars, "no.conforming.instance.exists",
-                            that.tvars, that.qtype, to2);
+                .setMessage("infer.no.conforming.instance.exists",
+                            that.tvars, that.qtype, to).setTvars(that.tvars);
         }
         for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail)
             maximizeInst((UndetVar) l.head, warn);
@@ -296,9 +349,32 @@
 
         // check bounds
         List<Type> targs = Type.map(undetvars, getInstFun);
-        targs = types.subst(targs, that.tvars, targs);
+        if (Type.containsAny(targs, that.tvars)) {
+            //replace uninferred type-vars
+            targs = types.subst(targs,
+                    that.tvars,
+                    instaniateAsUninferredVars(undetvars, that.tvars));
+        }
         return chk.checkType(warn.pos(), env, that.inst(targs, to, types), to);
     }
+    //where
+    private List<Type> instaniateAsUninferredVars(List<Type> undetvars, List<Type> tvars) {
+        ListBuffer<Type> new_targs = ListBuffer.lb();
+        //step 1 - create syntethic captured vars
+        for (Type t : undetvars) {
+            UndetVar uv = (UndetVar)t;
+            Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null);
+            new_targs = new_targs.append(newArg);
+        }
+        //step 2 - replace synthetic vars in their bounds
+        for (Type t : new_targs.toList()) {
+            CapturedType ct = (CapturedType)t;
+            ct.bound = types.subst(ct.bound, tvars, new_targs.toList());
+            WildcardType wt = new WildcardType(ct.bound, BoundKind.EXTENDS, syms.boundClass);
+            ct.wildcard = wt;
+        }
+        return new_targs.toList();
+    }
 
     /** Instantiate method type `mt' by finding instantiations of
      *  `tvars' so that method can be applied to `argtypes'.
@@ -324,6 +400,11 @@
         // set up lower bounds constraints for undetvars
         Type varargsFormal = useVarargs ? formals.last() : null;
         if (argtypes != Type.noTypes) {
+			if (varargsFormal == null &&
+		            actuals.size() != formals.size()) {
+		        throw unambiguousNoInstanceException
+		            .setMessage("infer.arg.length.mismatch");
+		    }
             while (actuals.nonEmpty() && formals.head != varargsFormal) {
                 Type formal = formals.head;
                 Type actual = actuals.head.baseType();
@@ -346,20 +427,23 @@
                     ? types.isConvertible(env, actual, undetFormal, warn)
                     : types.isSubtypeUnchecked(actual, undetFormal, warn);
                 if (!works) {
-                    throw unambiguousNoInstanceException
-                        .setMessage(tvars, "no.conforming.assignment.exists",
-                                    tvars, actualNoCapture, formal);
+                    if (tvars.nonEmpty()) {
+                        throw unambiguousNoInstanceException
+                            .setMessage("infer.no.conforming.assignment.exists",
+                                        tvars, actualNoCapture, formal).setTvars(tvars);
+                    }
+                    else {
+                        throw unambiguousNoInstanceException
+                            .setMessage("no.conforming.assignment.exists",
+                                        actualNoCapture, formal);
+                    }
                 }
                 formals = formals.tail;
                 actuals = actuals.tail;
                 actualsNoCapture = actualsNoCapture.tail;
             }
-            if (formals.head != varargsFormal || // not enough args
-                !useVarargs && actuals.nonEmpty()) { // too many args
-                // argument lists differ in length
-                throw unambiguousNoInstanceException
-                    .setMessage(tvars, "arg.length.mismatch");
-            }
+            if (formals.head != varargsFormal) // not enough args
+	            throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch");
 
             // for varargs arguments as well
             if (useVarargs) {
@@ -383,9 +467,16 @@
                     }
                     boolean works = types.isConvertible(env, actual, elemUndet, warn);
                     if (!works) {
-                        throw unambiguousNoInstanceException
-                            .setMessage(tvars, "no.conforming.assignment.exists",
-                                        tvars, actualNoCapture, elemType);
+                        if (tvars.nonEmpty()) {
+                            throw unambiguousNoInstanceException
+                                .setMessage("infer.no.conforming.assignment.exists",
+                                            tvars, actualNoCapture, elemType).setTvars(tvars);
+                        }
+                        else {
+                            throw unambiguousNoInstanceException
+                            .setMessage("no.conforming.assignment.exists",
+                                        actualNoCapture, elemType);
+                        }
                     }
                     actuals = actuals.tail;
                     actualsNoCapture = actualsNoCapture.tail;
@@ -461,7 +552,7 @@
                     if (!rs.argumentsAcceptable(env, capturedArgs2, formals,
                            allowBoxing, useVarargs, warn)) {
                       // inferred method is not applicable
-                      throw invalidInstanceException.setMessage(tvars, "inferred.do.not.conform.to.params", formals, argtypes);
+                      throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes).setTvars(tvars);
                     }
                     // check that inferred bounds conform to their bounds
                     checkWithinBounds(all_tvars,
@@ -478,7 +569,7 @@
         }
         else if (!rs.argumentsAcceptable(env, capturedArgs.toList(), types.subst(mt.getParameterTypes(), tvars, insttypes.toList()), allowBoxing, useVarargs, warn)) {
             // inferred method is not applicable
-            throw invalidInstanceException.setMessage(tvars, "inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes);
+            throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes).setTvars(tvars);
         }
         else {
             // return instantiated version of method type
@@ -549,8 +640,60 @@
             List<Type> bounds = types.subst(types.getBounds((TypeVar)tvs.head), tvars, arguments);
             if (!types.isSubtypeUnchecked(args.head, bounds, warn))
                 throw invalidInstanceException
-                    .setMessage(List.of(tvs.head), "inferred.do.not.conform.to.bounds",
-                                args.head, bounds);
+                    .setMessage("inferred.do.not.conform.to.bounds",
+                                args.head, bounds).setTvars(List.of(tvs.head));
         }
     }
+
+    /**
+     * Compute a synthetic method type corresponding to the requested polymorphic
+     * method signature. If no explicit return type is supplied, a provisional
+     * return type is computed (just Object in case of non-transitional 292)
+     */
+    Type instantiatePolymorphicSignatureInstance(Env<AttrContext> env, Type site,
+                                            Name name,
+                                            MethodSymbol spMethod,  // sig. poly. method or null if none
+                                            List<Type> argtypes,
+                                            List<Type> typeargtypes) {
+        final Type restype;
+        if (rs.allowTransitionalJSR292 && typeargtypes.nonEmpty()) {
+            restype = typeargtypes.head;
+        } else {
+            //The return type for a polymorphic signature call is computed from
+            //the enclosing tree E, as follows: if E is a cast, then use the
+            //target type of the cast expression as a return type; if E is an
+            //expression statement, the return type is 'void' - otherwise the
+            //return type is simply 'Object'.
+            switch (env.outer.tree.getTag()) {
+                case JCTree.TYPECAST:
+                    restype = ((JCTypeCast)env.outer.tree).clazz.type; break;
+                case JCTree.EXEC:
+                    restype = syms.voidType; break;
+                default:
+                    restype = syms.objectType;
+            }
+        }
+
+        List<Type> paramtypes = Type.map(argtypes, implicitArgType);
+        List<Type> exType = spMethod != null ?
+            spMethod.getThrownTypes() :
+            List.of(syms.throwableType); // make it throw all exceptions
+
+        MethodType mtype = new MethodType(paramtypes,
+                                          restype,
+                                          exType,
+                                          syms.methodClass);
+        return mtype;
+    }
+    //where
+        Mapping implicitArgType = new Mapping ("implicitArgType") {
+                public Type apply(Type t) {
+                    t = types.erasure(t);
+                    if (t.tag == BOT)
+                        // nulls type as the marker type Null (which has no instances)
+                        // infer as java.lang.Void for now
+                        t = types.boxedClass(syms.voidType).type;
+                    return t;
+                }
+        };
 }
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Tue Oct 19 16:26:29 2010 +0100
@@ -31,6 +31,7 @@
 
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.jvm.*;
+import com.sun.tools.javac.main.RecognizedOptions.PkgInfo;
 import com.sun.tools.javac.tree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
@@ -86,6 +87,8 @@
     private final Name classDollar;
     private Types types;
     private boolean debugLower;
+    private Scope.ScopeCounter scopeCounter;
+    private PkgInfo pkginfoOpt;
     private boolean emitDefenderMethodAnnos;
     private final boolean useMethodHandleLDC;
 
@@ -94,6 +97,7 @@
         names = Names.instance(context);
         log = Log.instance(context);
         syms = Symtab.instance(context);
+        scopeCounter = Scope.ScopeCounter.instance(context);
         rs = Resolve.instance(context);
         chk = Check.instance(context);
         attr = Attr.instance(context);
@@ -112,9 +116,10 @@
 
         types = Types.instance(context);
         Options options = Options.instance(context);
-        debugLower = options.get("debuglower") != null;
+        debugLower = options.isSet("debuglower");
+		pkginfoOpt = PkgInfo.get(options);
         emitDefenderMethodAnnos = options.get("emitDefenderMethodAnnos") != null;
-        useMethodHandleLDC = target.hasMethodHandleLiterals();
+        useMethodHandleLDC = target.hasMethodHandles();
     }
 
     /** The currently enclosing class.
@@ -595,7 +600,7 @@
         c.flatname = chk.localClassName(c);
         c.sourcefile = owner.sourcefile;
         c.completer = null;
-        c.members_field = new Scope(c);
+        c.members_field = new Scope.ClassScope(c, scopeCounter);
         c.flags_field = flags;
         ClassType ctype = (ClassType) c.type;
         ctype.supertype_field = syms.objectType;
@@ -2278,7 +2283,7 @@
     }
 
     public void visitTopLevel(JCCompilationUnit tree) {
-        if (tree.packageAnnotations.nonEmpty()) {
+        if (needPackageInfoClass(tree)) {
             Name name = names.package_info;
             long flags = Flags.ABSTRACT | Flags.INTERFACE;
             if (target.isPackageInfoSynthetic())
@@ -2300,6 +2305,23 @@
             translated.append(packageAnnotationsClass);
         }
     }
+    // where
+    private boolean needPackageInfoClass(JCCompilationUnit tree) {
+        switch (pkginfoOpt) {
+            case ALWAYS:
+                return true;
+            case LEGACY:
+                return tree.packageAnnotations.nonEmpty();
+            case NONEMPTY:
+                for (Attribute.Compound a: tree.packge.attributes_field) {
+                    Attribute.RetentionPolicy p = types.getRetention(a);
+                    if (p != Attribute.RetentionPolicy.SOURCE)
+                        return true;
+                }
+                return false;
+        }
+        throw new AssertionError();
+    }
 
     public void visitClassDef(JCClassDecl tree) {
         ClassSymbol currentClassPrev = currentClass;
@@ -2807,7 +2829,8 @@
     }
 //where
         private JCTree convert(JCTree tree, Type pt) {
-            if (tree.type == pt) return tree;
+            if (tree.type == pt || tree.type.tag == TypeTags.BOT)
+                return tree;
             JCTree result = make_at(tree.pos()).TypeCast(make.Type(pt), (JCExpression)tree);
             result.type = (tree.type.constValue() != null) ? cfolder.coerce(tree.type, pt)
                                                            : pt;
@@ -3052,8 +3075,17 @@
     /** Unbox an object to a primitive value. */
     JCExpression unbox(JCExpression tree, Type primitive) {
         Type unboxedType = types.unboxedType(tree.type);
-        // note: the "primitive" parameter is not used.  There muse be
-        // a conversion from unboxedType to primitive.
+        if (unboxedType.tag == NONE) {
+            unboxedType = primitive;
+            if (!unboxedType.isPrimitive())
+                throw new AssertionError(unboxedType);
+            make_at(tree.pos());
+            tree = make.TypeCast(types.boxedClass(unboxedType).type, tree);
+        } else {
+            // There must be a conversion from unboxedType to primitive.
+            if (!types.isSubtype(unboxedType, primitive))
+                throw new AssertionError(tree);
+        }
         make_at(tree.pos());
         Symbol valueSym = lookupMethod(tree.pos(),
                                        unboxedType.tsym.name.append(names.Value), // x.intValue()
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue Oct 19 16:26:29 2010 +0100
@@ -67,6 +67,7 @@
     private final Check chk;
     private final Attr attr;
     private final Symtab syms;
+    private final Scope.ScopeCounter scopeCounter;
     private final TreeMaker make;
     private final ClassReader reader;
     private final Todo todo;
@@ -92,6 +93,7 @@
         chk = Check.instance(context);
         attr = Attr.instance(context);
         syms = Symtab.instance(context);
+        scopeCounter = Scope.ScopeCounter.instance(context);
         make = TreeMaker.instance(context);
         reader = ClassReader.instance(context);
         todo = Todo.instance(context);
@@ -100,7 +102,7 @@
         diags = JCDiagnostic.Factory.instance(context);
         target = Target.instance(context);
         Options options = Options.instance(context);
-        skipAnnotations = options.get("skipAnnotations") != null;
+        skipAnnotations = options.isSet("skipAnnotations");
     }
 
     /** A queue for classes whose members still need to be entered into the
@@ -777,9 +779,17 @@
                 && types.isSameType(c.type, syms.deprecatedType))
                 s.flags_field |= Flags.DEPRECATED;
             // Internally to java.dyn, a @PolymorphicSignature annotation
-            // translates to a classfile attribute.
-            if (!c.type.isErroneous()
-                && types.isSameType(c.type, syms.polymorphicSignatureType)) {
+            // acts like a classfile attribute.
+            if (!c.type.isErroneous() &&
+                    types.isSameType(c.type, syms.polymorphicSignatureType)) {
+                if (!target.hasMethodHandles()) {
+                    // Somebody is compiling JDK7 source code to a JDK6 target.
+                    // Make it a strict warning, since it is unlikely but important.
+                    log.strictWarning(env.tree.pos(),
+                            "wrong.target.for.polymorphic.signature.definition",
+                            target.name);
+                }
+                // Pull the flag through for better diagnostics, even on a bad target.
                 s.flags_field |= Flags.POLYMORPHIC_SIGNATURE;
             }
             if (!annotated.add(a.type.tsym))
@@ -925,7 +935,7 @@
                 tp.accept(new TypeAnnotate(baseEnv));
             tree.accept(new TypeAnnotate(env));
 
-            chk.checkNonCyclic(tree.pos(), c.type);
+            chk.checkNonCyclicDecl(tree);
 
             attr.attribTypeVariables(tree.typarams, baseEnv);
 
@@ -1087,14 +1097,21 @@
 
 
     private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
-        Scope typaramScope = new Scope(tree.sym);
+        Scope baseScope = new Scope.ClassScope(tree.sym, scopeCounter);
+        //import already entered local classes into base scope
+        for (Scope.Entry e = env.outer.info.scope.elems ; e != null ; e = e.sibling) {
+            if (e.sym.isLocal()) {
+                baseScope.enter(e.sym);
+            }
+        }
+        //import current type-parameters into base scope
         if (tree.typarams != null)
             for (List<JCTypeParameter> typarams = tree.typarams;
                  typarams.nonEmpty();
                  typarams = typarams.tail)
-                typaramScope.enter(typarams.head.type.tsym);
+                baseScope.enter(typarams.head.type.tsym);
         Env<AttrContext> outer = env.outer; // the base clause can't see members of this class
-        Env<AttrContext> localEnv = outer.dup(tree, outer.info.dup(typaramScope));
+        Env<AttrContext> localEnv = outer.dup(tree, outer.info.dup(baseScope));
         localEnv.baseClause = true;
         localEnv.outer = outer;
         localEnv.info.isSelfCall = false;
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue Oct 19 16:26:29 2010 +0100
@@ -40,6 +40,8 @@
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.TypeTags.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 import javax.lang.model.element.ElementVisitor;
 
 import java.util.Map;
@@ -67,9 +69,13 @@
     JCDiagnostic.Factory diags;
     public final boolean boxingEnabled; // = source.allowBoxing();
     public final boolean varargsEnabled; // = source.allowVarargs();
-    public final boolean allowPolymorphicSignature;
+    public final boolean allowMethodHandles;
+    public final boolean allowInvokeDynamic;
+    public final boolean allowTransitionalJSR292;
     private final boolean debugResolve;
 
+    Scope polymorphicSignatureScope;
+
     public static Resolve instance(Context context) {
         Resolve instance = context.get(resolveKey);
         if (instance == null)
@@ -104,8 +110,17 @@
         boxingEnabled = source.allowBoxing();
         varargsEnabled = source.allowVarargs();
         Options options = Options.instance(context);
-        debugResolve = options.get("debugresolve") != null;
-        allowPolymorphicSignature = source.allowPolymorphicSignature() || options.get("invokedynamic") != null;
+        debugResolve = options.isSet("debugresolve");
+        allowTransitionalJSR292 = options.isSet("allowTransitionalJSR292");
+        Target target = Target.instance(context);
+        allowMethodHandles = allowTransitionalJSR292 ||
+                target.hasMethodHandles();
+        allowInvokeDynamic = (allowTransitionalJSR292 ||
+                target.hasInvokedynamic()) &&
+                options.isSet("invokedynamic");
+        polymorphicSignatureScope = new Scope(syms.noSymbol);
+
+        inapplicableMethodException = new InapplicableMethodException(diags);
     }
 
     /** error symbols, which are returned when resolution fails
@@ -244,7 +259,8 @@
     /* `sym' is accessible only if not overridden by
      * another symbol which is a member of `site'
      * (because, if it is overridden, `sym' is not strictly
-     * speaking a member of `site'.)
+     * speaking a member of `site'). A polymorphic signature method
+     * cannot be overridden (e.g. MH.invokeExact(Object[])).
      */
     private boolean notOverriddenIn(Type site, Symbol sym) {
         if (sym.kind != MTH || sym.isConstructor() || sym.isStatic())
@@ -252,6 +268,7 @@
         else {
             Symbol s2 = ((MethodSymbol)sym).implementation(site.tsym, types, true);
             return (s2 == null || s2 == sym ||
+                    s2.isPolymorphicSignatureGeneric() ||
                     !types.isSubSignature(types.memberType(site, s2), types.memberType(site, sym)));
         }
     }
@@ -301,21 +318,26 @@
                         boolean useVarargs,
                         Warner warn)
         throws Infer.InferenceException {
-        assert ((m.flags() & (POLYMORPHIC_SIGNATURE|HYPOTHETICAL)) != POLYMORPHIC_SIGNATURE);
-        if (useVarargs && (m.flags() & VARARGS) == 0) return null;
+        boolean polymorphicSignature = (m.isPolymorphicSignatureGeneric() && allowMethodHandles) ||
+                                        isTransitionalDynamicCallSite(site, m);
+        if (useVarargs && (m.flags() & VARARGS) == 0)
+            throw inapplicableMethodException.setMessage(null);
         Type mt = types.memberType(site, m);
 
         // tvars is the list of formal type variables for which type arguments
         // need to inferred.
         List<Type> tvars = env.info.tvars;
         if (typeargtypes == null) typeargtypes = List.nil();
-        if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
+        if (allowTransitionalJSR292 && polymorphicSignature && typeargtypes.nonEmpty()) {
+            //transitional 292 call sites might have wrong number of targs
+        }
+        else if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
             // This is not a polymorphic method, but typeargs are supplied
             // which is fine, see JLS3 15.12.2.1
         } else if (mt.tag == FORALL && typeargtypes.nonEmpty()) {
             ForAll pmt = (ForAll) mt;
             if (typeargtypes.length() != pmt.tvars.length())
-                return null;
+                throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
             // Check type arguments are within bounds
             List<Type> formals = pmt.tvars;
             List<Type> actuals = typeargtypes;
@@ -327,7 +349,7 @@
                                                 pmt.tvars, typeargtypes);
                 for (; bounds.nonEmpty(); bounds = bounds.tail)
                     if (!types.isSubtypeUnchecked(actual, bounds.head, warn))
-                        return null;
+                        throw inapplicableMethodException.setMessage("explicit.param.do.not.conform.to.bounds",actuals.head, bounds);
                 formals = formals.tail;
                 actuals = actuals.tail;
             }
@@ -340,7 +362,8 @@
         }
 
         // find out whether we need to go the slow route via infer
-        boolean instNeeded = tvars.tail != null/*inlined: tvars.nonEmpty()*/;
+        boolean instNeeded = tvars.tail != null || /*inlined: tvars.nonEmpty()*/
+                polymorphicSignature;
         for (List<Type> l = argtypes;
              l.tail != null/*inlined: l.nonEmpty()*/ && !instNeeded;
              l = l.tail) {
@@ -348,8 +371,9 @@
         }
 
         if (instNeeded)
-            return
-            infer.instantiateMethod(env,
+            return polymorphicSignature ?
+                infer.instantiatePolymorphicSignatureInstance(env, site, m.name, (MethodSymbol)m, argtypes, typeargtypes) :
+                infer.instantiateMethod(env,
                                     tvars,
                                     (MethodType)mt,
                                     m,
@@ -357,11 +381,18 @@
                                     allowBoxing,
                                     useVarargs,
                                     warn);
-        return
-            argumentsAcceptable(env, argtypes, mt.getParameterTypes(),
-                                allowBoxing, useVarargs, warn)
-            ? mt
-            : null;
+
+        checkRawArgumentsAcceptable(env, argtypes, mt.getParameterTypes(),
+                                allowBoxing, useVarargs, warn);
+        return mt;
+    }
+
+    boolean isTransitionalDynamicCallSite(Type site, Symbol sym) {
+        return allowTransitionalJSR292 &&  // old logic that doesn't use annotations
+                !sym.isPolymorphicSignatureInstance() &&
+                ((allowMethodHandles && site == syms.methodHandleType && // invokeExact, invokeGeneric, invoke
+                    (sym.name == names.invoke && sym.isPolymorphicSignatureGeneric())) ||
+                (site == syms.invokeDynamicType && allowInvokeDynamic)); // InvokeDynamic.XYZ
     }
 
     /** Same but returns null instead throwing a NoInstanceException
@@ -377,7 +408,7 @@
         try {
             return rawInstantiate(env, site, m, argtypes, typeargtypes,
                                   allowBoxing, useVarargs, warn);
-        } catch (Infer.InferenceException ex) {
+        } catch (InapplicableMethodException ex) {
             return null;
         }
     }
@@ -389,8 +420,25 @@
                                 boolean allowBoxing,
                                 boolean useVarargs,
                                 Warner warn) {
-        if (argtypes == Type.noTypes) return true;
+	try {
+            checkRawArgumentsAcceptable(env, argtypes, formals, allowBoxing, useVarargs, warn);
+            return true;
+        } catch (InapplicableMethodException ex) {
+            return false;
+        }
+    }
+    void checkRawArgumentsAcceptable(Env<AttrContext> env, List<Type> argtypes,
+                                List<Type> formals,
+                                boolean allowBoxing,
+                                boolean useVarargs,
+                                Warner warn) {
+        if (argtypes == Type.noTypes) return;
         Type varargsFormal = useVarargs ? formals.last() : null;
+        if (varargsFormal == null &&
+                argtypes.size() != formals.size()) {
+            throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+        }
+
         while (argtypes.nonEmpty() && formals.head != varargsFormal) {
             Type actual = argtypes.head.tag == FORALL ?
                 infer.instantiateArg(env, (ForAll)argtypes.head, formals.head, warn) :
@@ -398,24 +446,56 @@
             boolean works = allowBoxing
                 ? types.isConvertible(env, actual, formals.head, warn)
                 : types.isSubtypeUnchecked(actual, formals.head, warn);
-            if (!works) return false;
+            if (!works)
+                throw inapplicableMethodException.setMessage("no.conforming.assignment.exists",
+                        actual,
+                        formals.head);
             argtypes = argtypes.tail;
             formals = formals.tail;
         }
-        if (formals.head != varargsFormal) return false; // not enough args
-        if (!useVarargs)
-            return argtypes.isEmpty();
-        Type elt = types.elemtype(varargsFormal);
-        while (argtypes.nonEmpty()) {
-            Type actual = argtypes.head.tag == FORALL ?
-                infer.instantiateArg(env, (ForAll)argtypes.head, elt, warn) :
-                argtypes.head;
-            if (!types.isConvertible(env, actual, elt, warn))
-                return false;
-            argtypes = argtypes.tail;
+		
+        if (formals.head != varargsFormal)
+            throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+
+        if (useVarargs) {
+            Type elt = types.elemtype(varargsFormal);
+    	    while (argtypes.nonEmpty()) {
+    	        Type actual = argtypes.head.tag == FORALL ?
+    	            infer.instantiateArg(env, (ForAll)argtypes.head, elt, warn) :
+                    argtypes.head;
+    	        if (!types.isConvertible(env, actual, elt, warn))
+    	            throw inapplicableMethodException.setMessage("varargs.argument.mismatch",
+                            actual,
+                            elt);
+    	        argtypes = argtypes.tail;
+    	    }
         }
-        return true;
     }
+    // where
+        public static class InapplicableMethodException extends RuntimeException {
+            private static final long serialVersionUID = 0;
+
+            JCDiagnostic diagnostic;
+            JCDiagnostic.Factory diags;
+
+            InapplicableMethodException(JCDiagnostic.Factory diags) {
+                this.diagnostic = null;
+                this.diags = diags;
+            }
+            InapplicableMethodException setMessage(String key) {
+                this.diagnostic = key != null ? diags.fragment(key) : null;
+                return this;
+            }
+            InapplicableMethodException setMessage(String key, Object... args) {
+                this.diagnostic = key != null ? diags.fragment(key, args) : null;
+                return this;
+            }
+
+            public JCDiagnostic getDiagnostic() {
+                return diagnostic;
+            }
+        }
+        private final InapplicableMethodException inapplicableMethodException;
 
 /* ***************************************************************************
  *  Symbol lookup
@@ -576,6 +656,7 @@
      *  @param allowBoxing Allow boxing conversions of arguments.
      *  @param useVarargs Box trailing arguments into an array for varargs.
      */
+    @SuppressWarnings("fallthrough")
     Symbol selectBest(Env<AttrContext> env,
                       Type site,
                       List<Type> argtypes,
@@ -588,30 +669,17 @@
         if (sym.kind == ERR) return bestSoFar;
         if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
         assert sym.kind < AMBIGUOUS;
-        if ((sym.flags() & POLYMORPHIC_SIGNATURE) != 0 && allowPolymorphicSignature) {
-            assert(site.tag == CLASS);
-            // Never match a MethodHandle.invoke directly.
-            if (useVarargs | allowBoxing | operator)
-                return bestSoFar;
-            // Supply an exactly-typed implicit method instead.
-            sym = findPolymorphicSignatureInstance(env, sym.owner.type, sym.name, (MethodSymbol) sym, argtypes, typeargtypes);
-        }
         try {
-            if (rawInstantiate(env, site, sym, argtypes, typeargtypes,
-                               allowBoxing, useVarargs, Warner.noWarnings) == null) {
-                // inapplicable
-                switch (bestSoFar.kind) {
-                case ABSENT_MTH: return wrongMethod.setWrongSym(sym);
-                case WRONG_MTH: return wrongMethods;
-                default: return bestSoFar;
-                }
-            }
-        } catch (Infer.InferenceException ex) {
+            rawInstantiate(env, site, sym, argtypes, typeargtypes,
+                               allowBoxing, useVarargs, Warner.noWarnings);
+        } catch (InapplicableMethodException ex) {
             switch (bestSoFar.kind) {
             case ABSENT_MTH:
                 return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
             case WRONG_MTH:
-                return wrongMethods;
+                wrongMethods.addCandidate(currentStep, wrongMethod.sym, wrongMethod.explanation);
+            case WRONG_MTHS:
+                return wrongMethods.addCandidate(currentStep, sym, ex.getDiagnostic());
             default:
                 return bestSoFar;
             }
@@ -620,7 +688,7 @@
             return (bestSoFar.kind == ABSENT_MTH)
                 ? new AccessError(env, site, sym)
                 : bestSoFar;
-        }
+            }
         return (bestSoFar.kind > AMBIGUOUS)
             ? sym
             : mostSpecific(sym, bestSoFar, env, site,
@@ -769,10 +837,6 @@
                       boolean useVarargs,
                       boolean operator) {
         Symbol bestSoFar = methodNotFound;
-        if (needsImplicitResolution(site, name, useVarargs, allowBoxing, operator)) {
-            // supply an exactly-typed implicit method in java.dyn.InvokeDynamic
-            bestSoFar = findPolymorphicSignatureInstance(env, site, name, null, argtypes, typeargtypes);
-        }
         return findMethod(env,
                           site,
                           name,
@@ -917,109 +981,6 @@
         return bestSoFar;
     }
 
-    /** Find or create an implicit method of exactly the given type (after erasure).
-     *  Searches in a side table, not the main scope of the site.
-     *  This emulates the lookup process required by JSR 292 in JVM.
-     *  @param env       The current environment.
-     *  @param site      The original type from where the selection
-     *                   takes place.
-     *  @param name      The method's name.
-     *  @param argtypes  The method's value arguments.
-     *  @param typeargtypes The method's type arguments
-     */
-    Symbol findPolymorphicSignatureInstance(Env<AttrContext> env,
-                                            Type site,
-                                            Name name,
-                                            MethodSymbol spMethod,  // sig. poly. method or null if none
-                                            List<Type> argtypes,
-                                            List<Type> typeargtypes) {
-        assert allowPolymorphicSignature;
-        //assert site == syms.invokeDynamicType || site == syms.methodHandleType : site;
-        ClassSymbol c = (ClassSymbol) site.tsym;
-        Scope implicit = c.members().next;
-        if (implicit == null) {
-            c.members().next = implicit = new Scope(c);
-        }
-        Type restype;
-        List<Type> thrown = List.nil();
-        List<Type> paramtypes;
-        long flags = 0;
-        if (types.isFunctionType(site)) {
-            paramtypes = site.getParameterTypes();
-            restype = site.getReturnType();
-            thrown = site.getThrownTypes();
-        }
-        else {
-            if (typeargtypes.isEmpty()) {
-                restype = syms.objectType;
-            } else {
-                restype = typeargtypes.head;
-                if (!typeargtypes.tail.isEmpty())
-                    return methodNotFound;
-            }
-            paramtypes = Type.map(argtypes, implicitArgType);
-            if (spMethod != null) {
-                thrown = spMethod.getThrownTypes();
-                flags = spMethod.flags() & AccessFlags;
-            } else {
-                // make it throw all exceptions
-                //assert(site == syms.invokeDynamicType);
-                thrown = List.of(syms.throwableType);
-                flags = PUBLIC | STATIC;
-            }
-        }
-        
-        MethodType mtype = new MethodType(paramtypes,
-                                          restype,
-                                          thrown,
-                                          syms.methodClass);
-        flags |= ABSTRACT | HYPOTHETICAL | POLYMORPHIC_SIGNATURE;
-        if (site == syms.invokeDynamicType)  flags |= STATIC;
-        else if (types.isFunctionType(site)) {
-            flags |= LAMBDA;
-        }
-        Symbol m = null;
-        for (Scope.Entry e = implicit.lookup(name);
-             e.scope != null;
-             e = e.next()) {
-            Symbol sym = e.sym;
-            assert sym.kind == MTH;
-            if (types.isSameType(mtype, sym.type)
-                && (sym.flags() & STATIC) == (flags & STATIC)) {
-                m = sym;
-                break;
-            }
-        }
-        if (m == null) {
-            // create the desired method
-            m = new MethodSymbol(flags, name, mtype, c);
-            implicit.enter(m);
-        }
-        boolean argsOk = argumentsAcceptable(env, argtypes, types.memberType(site, m).getParameterTypes(),
-                                   true, false, Warner.noWarnings);
-        if (types.isFunctionType(site) && !argsOk)
-            return wrongMethod.setWrongSym(m);
-        if (!argumentsAcceptable(env, argtypes, types.memberType(site, m).getParameterTypes(),
-                                   true, false, Warner.noWarnings) ||
-            instantiate(env, site, m, argtypes, typeargtypes, true, false, Warner.noWarnings) == null) {
-            throw new AssertionError();
-        }
-        return m;
-    }
-    //where
-        Mapping implicitArgType = new Mapping ("implicitArgType") {
-                public Type apply(Type t) { return implicitArgType(t); }
-            };
-        Type implicitArgType(Type argType) {
-            argType = types.erasure(argType);
-            if (argType.tag == BOT)
-                // nulls type as the marker type Null (which has no instances)
-                // TO DO: figure out how to access java.lang.Null safely, else throw nice error
-                //argType = types.boxedClass(syms.botType).type;
-                argType = types.boxedClass(syms.voidType).type;  // REMOVE
-            return argType;
-        }
-
     /** Load toplevel or member class with given fully qualified name and
      *  verify that it is accessible.
      *  @param env       The current environment.
@@ -1354,11 +1315,12 @@
                          Name name,
                          List<Type> argtypes,
                          List<Type> typeargtypes) {
-        Symbol sym = methodNotFound;
+        Symbol sym = startResolution();
         List<MethodResolutionPhase> steps = methodResolutionSteps;
         while (steps.nonEmpty() &&
                steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
                sym.kind >= ERRONEOUS) {
+            currentStep = steps.head;
             sym = findFun(env, name, argtypes, typeargtypes,
                     steps.head.isBoxingRequired,
                     env.info.varArgs = steps.head.isVarargsRequired);
@@ -1375,6 +1337,12 @@
         return sym;
     }
 
+    private Symbol startResolution() {
+        wrongMethod.clear();
+        wrongMethods.clear();
+        return methodNotFound;
+    }
+
     /** Resolve a qualified method identifier
      *  @param pos       The position to use for error reporting.
      *  @param env       The environment current at the method invocation.
@@ -1387,33 +1355,87 @@
     Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env<AttrContext> env,
                                   Type site, Name name, List<Type> argtypes,
                                   List<Type> typeargtypes) {
-        Symbol sym = methodNotFound;
+        Symbol sym = startResolution();
         List<MethodResolutionPhase> steps = methodResolutionSteps;
         while (steps.nonEmpty() &&
                steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
                sym.kind >= ERRONEOUS) {
+            currentStep = steps.head;
             sym = findMethod(env, site, name, argtypes, typeargtypes,
                     steps.head.isBoxingRequired(),
                     env.info.varArgs = steps.head.isVarargsRequired(), false);
             methodResolutionCache.put(steps.head, sym);
             steps = steps.tail;
         }
-        if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error
-            MethodResolutionPhase errPhase =
-                    firstErroneousResolutionPhase();
-            sym = access(methodResolutionCache.get(errPhase),
-                    pos, site, name, true, argtypes, typeargtypes);
-            env.info.varArgs = errPhase.isVarargsRequired;
+        if (sym.kind >= AMBIGUOUS) {
+            if (site.tsym.isPolymorphicSignatureGeneric() ||
+                    isTransitionalDynamicCallSite(site, sym)) {
+                //polymorphic receiver - synthesize new method symbol
+                env.info.varArgs = false;
+                sym = findPolymorphicSignatureInstance(env,
+                        site, name, null, argtypes, typeargtypes);
+            }
+            else {
+                //if nothing is found return the 'first' error
+                MethodResolutionPhase errPhase =
+                        firstErroneousResolutionPhase();
+                sym = access(methodResolutionCache.get(errPhase),
+                        pos, site, name, true, argtypes, typeargtypes);
+                env.info.varArgs = errPhase.isVarargsRequired;
+            }
+        } else if (allowMethodHandles && sym.isPolymorphicSignatureGeneric()) {
+            //non-instantiated polymorphic signature - synthesize new method symbol
+            env.info.varArgs = false;
+            sym = findPolymorphicSignatureInstance(env,
+                    site, name, (MethodSymbol)sym, argtypes, typeargtypes);
         }
         return sym;
     }
 
-    boolean needsImplicitResolution(Type site, Name name, boolean useVarargs, boolean allowBoxing, boolean operator) {
-        return ((site.tsym.flags() & POLYMORPHIC_SIGNATURE) != 0 &&
-                allowPolymorphicSignature &&
-                site.tag == CLASS &&
-                !(useVarargs | allowBoxing | operator)) ||
-                types.isFunctionType(site) && name == names.empty;
+    /** Find or create an implicit method of exactly the given type (after erasure).
+     *  Searches in a side table, not the main scope of the site.
+     *  This emulates the lookup process required by JSR 292 in JVM.
+     *  @param env       Attribution environment
+     *  @param site      The original type from where the selection takes place.
+     *  @param name      The method's name.
+     *  @param spMethod  A template for the implicit method, or null.
+     *  @param argtypes  The required argument types.
+     *  @param typeargtypes  The required type arguments.
+     */
+    Symbol findPolymorphicSignatureInstance(Env<AttrContext> env, Type site,
+                                            Name name,
+                                            MethodSymbol spMethod,  // sig. poly. method or null if none
+                                            List<Type> argtypes,
+                                            List<Type> typeargtypes) {
+        if (typeargtypes.nonEmpty() && (site.tsym.isPolymorphicSignatureGeneric() ||
+                (spMethod != null && spMethod.isPolymorphicSignatureGeneric()))) {
+            log.warning(env.tree.pos(), "type.parameter.on.polymorphic.signature");
+        }
+
+        Type mtype = infer.instantiatePolymorphicSignatureInstance(env,
+                site, name, spMethod, argtypes, typeargtypes);
+        long flags = ABSTRACT | HYPOTHETICAL | POLYMORPHIC_SIGNATURE |
+                    (spMethod != null ?
+                        spMethod.flags() & Flags.AccessFlags :
+                        Flags.PUBLIC | Flags.STATIC);
+        Symbol m = null;
+        for (Scope.Entry e = polymorphicSignatureScope.lookup(name);
+             e.scope != null;
+             e = e.next()) {
+            Symbol sym = e.sym;
+            if (types.isSameType(mtype, sym.type) &&
+                (sym.flags() & Flags.STATIC) == (flags & Flags.STATIC) &&
+                types.isSameType(sym.owner.type, site)) {
+               m = sym;
+               break;
+            }
+        }
+        if (m == null) {
+            // create the desired method
+            m = new MethodSymbol(flags, name, mtype, site.tsym);
+            polymorphicSignatureScope.enter(m);
+        }
+        return m;
     }
 
     /** Resolve a qualified method identifier, throw a fatal error if not
@@ -1452,11 +1474,12 @@
                               Type site,
                               List<Type> argtypes,
                               List<Type> typeargtypes) {
-        Symbol sym = methodNotFound;
+        Symbol sym = startResolution();
         List<MethodResolutionPhase> steps = methodResolutionSteps;
         while (steps.nonEmpty() &&
                steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
                sym.kind >= ERRONEOUS) {
+            currentStep = steps.head;
             sym = resolveConstructor(pos, env, site, argtypes, typeargtypes,
                     steps.head.isBoxingRequired(),
                     env.info.varArgs = steps.head.isVarargsRequired());
@@ -1486,30 +1509,35 @@
                               Env<AttrContext> env,
                               Type site,
                               List<Type> argtypes,
-                              List<Type> typeargtypes, boolean reportErrors) {
-        Symbol sym = methodNotFound;
-        JCDiagnostic explanation = null;
+                              List<Type> typeargtypes) {
+        Symbol sym = startResolution();
         List<MethodResolutionPhase> steps = methodResolutionSteps;
         while (steps.nonEmpty() &&
                steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
                sym.kind >= ERRONEOUS) {
+            currentStep = steps.head;
             sym = resolveConstructor(pos, env, site, argtypes, typeargtypes,
                     steps.head.isBoxingRequired(),
                     env.info.varArgs = steps.head.isVarargsRequired());
             methodResolutionCache.put(steps.head, sym);
-            if (sym.kind == WRONG_MTH &&
-                    ((InapplicableSymbolError)sym).explanation != null) {
-                //if the symbol is an inapplicable method symbol, then the
-                //explanation contains the reason for which inference failed
-                explanation = ((InapplicableSymbolError)sym).explanation;
-            }
             steps = steps.tail;
         }
-        if (sym.kind >= AMBIGUOUS && reportErrors) {
-            String key = explanation == null ?
-                "cant.apply.diamond" :
-                "cant.apply.diamond.1";
-            log.error(pos, key, diags.fragment("diamond", site.tsym), explanation);
+        if (sym.kind >= AMBIGUOUS) {
+            final JCDiagnostic details = sym.kind == WRONG_MTH ?
+                ((InapplicableSymbolError)sym).explanation :
+                null;
+            Symbol errSym = new ResolveError(WRONG_MTH, "diamond error") {
+                @Override
+                JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) {
+                    String key = details == null ?
+                        "cant.apply.diamond" :
+                        "cant.apply.diamond.1";
+                    return diags.create(dkind, log.currentSource(), pos, key, diags.fragment("diamond", site.tsym), details);
+                }
+            };
+            MethodResolutionPhase errPhase = firstErroneousResolutionPhase();
+            sym = access(errSym, pos, site, names.init, true, argtypes, typeargtypes);
+            env.info.varArgs = errPhase.isVarargsRequired();
         }
         return sym;
     }
@@ -1702,8 +1730,10 @@
             List<Type> typeargtypes) {
         JCDiagnostic d = error.getDiagnostic(JCDiagnostic.DiagnosticType.ERROR,
                 pos, site, name, argtypes, typeargtypes);
-        if (d != null)
+        if (d != null) {
+            d.setFlag(DiagnosticFlag.RESOLVE_ERROR);
             log.report(d);
+        }
     }
 
     private final LocalizedString noArgs = new LocalizedString("compiler.misc.no.args");
@@ -1911,7 +1941,8 @@
          */
         InapplicableSymbolError setWrongSym(Symbol sym, JCDiagnostic explanation) {
             this.sym = sym;
-            this.explanation = explanation;
+            if (this.sym == sym && explanation != null)
+                this.explanation = explanation; //update the details
             return this;
         }
 
@@ -1919,7 +1950,6 @@
          */
         InapplicableSymbolError setWrongSym(Symbol sym) {
             this.sym = sym;
-            this.explanation = null;
             return this;
         }
 
@@ -1963,6 +1993,10 @@
             }
         }
 
+        void clear() {
+            explanation = null;
+        }
+
         @Override
         public Symbol access(Name name, TypeSymbol location) {
             return types.createErrorType(name, location, syms.errSymbol.type).tsym;
@@ -1975,6 +2009,9 @@
      * given an actual arguments/type argument list.
      */
     class InapplicableSymbolsError extends ResolveError {
+
+        private List<Candidate> candidates = List.nil();
+
         InapplicableSymbolsError(Symbol sym) {
             super(WRONG_MTHS, "inapplicable symbols");
         }
@@ -1986,8 +2023,86 @@
                 Name name,
                 List<Type> argtypes,
                 List<Type> typeargtypes) {
-            return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
+            if (candidates.nonEmpty()) {
+                JCDiagnostic err = diags.create(dkind,
+                        log.currentSource(),
+                        pos,
+                        "cant.apply.symbols",
+                        name == names.init ? KindName.CONSTRUCTOR : absentKind(kind),
+                        getName(),
+                        argtypes);
+                return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(site));
+            } else {
+                return new SymbolNotFoundError(ABSENT_MTH).getDiagnostic(dkind, pos,
                     site, name, argtypes, typeargtypes);
+            }
+        }
+
+        //where
+        List<JCDiagnostic> candidateDetails(Type site) {
+            List<JCDiagnostic> details = List.nil();
+            for (Candidate c : candidates)
+                details = details.prepend(c.getDiagnostic(site));
+            return details.reverse();
+        }
+
+        Symbol addCandidate(MethodResolutionPhase currentStep, Symbol sym, JCDiagnostic details) {
+            Candidate c = new Candidate(currentStep, sym, details);
+            if (c.isValid() && !candidates.contains(c))
+                candidates = candidates.append(c);
+            return this;
+        }
+
+        void clear() {
+            candidates = List.nil();
+        }
+
+        private Name getName() {
+            Symbol sym = candidates.head.sym;
+            return sym.name == names.init ?
+                sym.owner.name :
+                sym.name;
+        }
+
+        private class Candidate {
+
+            final MethodResolutionPhase step;
+            final Symbol sym;
+            final JCDiagnostic details;
+
+            private Candidate(MethodResolutionPhase step, Symbol sym, JCDiagnostic details) {
+                this.step = step;
+                this.sym = sym;
+                this.details = details;
+            }
+
+            JCDiagnostic getDiagnostic(Type site) {
+                return diags.fragment("inapplicable.method",
+                        Kinds.kindName(sym),
+                        sym.location(site, types),
+                        sym.asMemberOf(site, types),
+                        details);
+            }
+
+            @Override
+            public boolean equals(Object o) {
+                if (o instanceof Candidate) {
+                    Symbol s1 = this.sym;
+                    Symbol s2 = ((Candidate)o).sym;
+                    if  ((s1 != s2 &&
+                        (s1.overrides(s2, s1.owner.type.tsym, types, false) ||
+                        (s2.overrides(s1, s2.owner.type.tsym, types, false)))) ||
+                        ((s1.isConstructor() || s2.isConstructor()) && s1.owner != s2.owner))
+                        return true;
+                }
+                return false;
+            }
+
+            boolean isValid() {
+                return sym.owner != syms.predefClass &&
+                        (((sym.flags() & VARARGS) != 0 && step == VARARITY) ||
+                          (sym.flags() & VARARGS) == 0 && step == (boxingEnabled ? BOX : BASIC));
+            }
         }
     }
 
@@ -2151,6 +2266,8 @@
 
     final List<MethodResolutionPhase> methodResolutionSteps = List.of(BASIC, BOX, VARARITY);
 
+    private MethodResolutionPhase currentStep = null;
+
     private MethodResolutionPhase firstErroneousResolutionPhase() {
         MethodResolutionPhase bestSoFar = BASIC;
         Symbol sym = methodNotFound;
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Tue Oct 19 16:26:29 2010 +0100
@@ -287,12 +287,13 @@
                            ListBuffer<JCTree> bridges) {
         if (sym.kind == MTH &&
             sym.name != names.init &&
-            (sym.flags() & (PRIVATE | SYNTHETIC | STATIC)) == 0 &&
+            (sym.flags() & (PRIVATE | STATIC)) == 0 &&
+            (sym.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) != SYNTHETIC &&
             sym.isMemberOf(origin, types))
         {
             MethodSymbol meth = (MethodSymbol)sym;
             MethodSymbol bridge = meth.binaryImplementation(origin, types);
-            MethodSymbol impl = meth.implementation(origin, types, true);
+            MethodSymbol impl = meth.implementation(origin, types, true, overrideBridgeFilter);
             if (bridge == null ||
                 bridge == meth ||
                 (impl != null && !bridge.owner.isSubClass(impl.owner, types))) {
@@ -308,7 +309,7 @@
                     // reflection design error.
                     addBridge(pos, meth, impl, origin, false, bridges);
                 }
-            } else if ((bridge.flags() & SYNTHETIC) != 0) {
+            } else if ((bridge.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) == SYNTHETIC) {
                 MethodSymbol other = overridden.get(bridge);
                 if (other != null && other != meth) {
                     if (impl == null || !impl.overrides(other, origin, types, true)) {
@@ -331,6 +332,11 @@
         }
     }
     // where
+        Filter<Symbol> overrideBridgeFilter = new Filter<Symbol>() {
+            public boolean accepts(Symbol s) {
+                return (s.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) != SYNTHETIC;
+            }
+        };
         /**
          * @param method The symbol for which a bridge might have to be added
          * @param impl The implementation of method
@@ -788,6 +794,90 @@
         return types.erasure(t);
     }
 
+    private boolean boundsRestricted(ClassSymbol c) {
+        Type st = types.supertype(c.type);
+        if (st.isParameterized()) {
+            List<Type> actuals = st.allparams();
+            List<Type> formals = st.tsym.type.allparams();
+            while (!actuals.isEmpty() && !formals.isEmpty()) {
+                Type actual = actuals.head;
+                Type formal = formals.head;
+
+                if (!types.isSameType(types.erasure(actual),
+                        types.erasure(formal)))
+                    return true;
+
+                actuals = actuals.tail;
+                formals = formals.tail;
+            }
+        }
+        return false;
+    }
+
+    private List<JCTree> addOverrideBridgesIfNeeded(DiagnosticPosition pos,
+                                    final ClassSymbol c) {
+        ListBuffer<JCTree> buf = ListBuffer.lb();
+        if (c.isInterface() || !boundsRestricted(c))
+            return buf.toList();
+        Type t = types.supertype(c.type);
+            Scope s = t.tsym.members();
+            if (s.elems != null) {
+                for (Symbol sym : s.getElements(new NeedsOverridBridgeFilter(c))) {
+
+                    MethodSymbol m = (MethodSymbol)sym;
+                    MethodSymbol member = (MethodSymbol)m.asMemberOf(c.type, types);
+                    MethodSymbol impl = m.implementation(c, types, false);
+
+                    if ((impl == null || impl.owner != c) &&
+                            !types.isSameType(member.erasure(types), m.erasure(types))) {
+                        addOverrideBridges(pos, m, member, c, buf);
+                    }
+                }
+            }
+        return buf.toList();
+    }
+    // where
+        class NeedsOverridBridgeFilter implements Filter<Symbol> {
+
+            ClassSymbol c;
+
+            NeedsOverridBridgeFilter(ClassSymbol c) {
+                this.c = c;
+            }
+            public boolean accepts(Symbol s) {
+                return s.kind == MTH &&
+                            !s.isConstructor() &&
+                            s.isInheritedIn(c, types) &&
+                            (s.flags() & FINAL) == 0 &&
+                            (s.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) != SYNTHETIC;
+            }
+        }
+
+    private void addOverrideBridges(DiagnosticPosition pos,
+                                    MethodSymbol impl,
+                                    MethodSymbol member,
+                                    ClassSymbol c,
+                                    ListBuffer<JCTree> bridges) {
+        Type implErasure = impl.erasure(types);
+        long flags = (impl.flags() & AccessFlags) | SYNTHETIC | BRIDGE | OVERRIDE_BRIDGE;
+        member = new MethodSymbol(flags, member.name, member.type, c);
+        JCMethodDecl md = make.MethodDef(member, null);
+        JCExpression receiver = make.Super(types.supertype(c.type).tsym.erasure(types), c);
+        Type calltype = erasure(impl.type.getReturnType());
+        JCExpression call =
+            make.Apply(null,
+                       make.Select(receiver, impl).setType(calltype),
+                       translateArgs(make.Idents(md.params),
+                                     implErasure.getParameterTypes(), null), false)
+            .setType(calltype);
+        JCStatement stat = (member.getReturnType().tag == VOID)
+            ? make.Exec(call)
+            : make.Return(coerce(call, member.erasure(types).getReturnType()));
+        md.body = make.Block(0, List.of(stat));
+        c.members().enter(member);
+        bridges.append(md);
+    }
+
 /**************************************************************************
  * main method
  *************************************************************************/
@@ -820,6 +910,7 @@
                 make.at(tree.pos);
                 if (addBridges) {
                     ListBuffer<JCTree> bridges = new ListBuffer<JCTree>();
+                    bridges.appendList(addOverrideBridgesIfNeeded(tree, c));
                     if ((tree.sym.flags() & INTERFACE) == 0)
                         addBridges(tree.pos(), tree.sym, bridges);
                     tree.defs = bridges.toList().prependList(tree.defs);
--- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -150,8 +150,8 @@
 
         useZipFileIndex = System.getProperty("useJavaUtilZip") == null;// TODO: options.get("useJavaUtilZip") == null;
 
-        mmappedIO = options.get("mmappedIO") != null;
-        ignoreSymbolFile = options.get("ignore.symbol.file") != null;
+        mmappedIO = options.isSet("mmappedIO");
+        ignoreSymbolFile = options.isSet("ignore.symbol.file");
     }
 
     public JavaFileObject getFileForInput(String name) {
@@ -435,7 +435,7 @@
                     zdir = new ZipFile(zipFileName);
                 }
                 else {
-                    usePreindexedCache = options.get("usezipindex") != null;
+                    usePreindexedCache = options.isSet("usezipindex");
                     preindexCacheLocation = options.get("java.io.tmpdir");
                     String optCacheLoc = options.get("cachezipindexdir");
 
@@ -469,7 +469,7 @@
                                     null,
                                     usePreindexedCache,
                                     preindexCacheLocation,
-                                    options.get("writezipindexfiles") != null));
+                                    options.isSet("writezipindexfiles")));
                     }
                 }
                 else {
@@ -482,7 +482,7 @@
                                     symbolFilePrefix,
                                     usePreindexedCache,
                                     preindexCacheLocation,
-                                    options.get("writezipindexfiles") != null));
+                                    options.isSet("writezipindexfiles")));
                     }
                 }
             } catch (FileNotFoundException ex) {
@@ -605,7 +605,7 @@
         nullCheck(className);
         nullCheck(kind);
         if (!sourceOrClass.contains(kind))
-            throw new IllegalArgumentException("Invalid kind " + kind);
+            throw new IllegalArgumentException("Invalid kind: " + kind);
         return getFileForInput(location, RelativeFile.forClass(className, kind));
     }
 
@@ -658,7 +658,7 @@
         nullCheck(className);
         nullCheck(kind);
         if (!sourceOrClass.contains(kind))
-            throw new IllegalArgumentException("Invalid kind " + kind);
+            throw new IllegalArgumentException("Invalid kind: " + kind);
         return getFileForOutput(location, RelativeFile.forClass(className, kind), sibling);
     }
 
@@ -672,7 +672,7 @@
         // validatePackageName(packageName);
         nullCheck(packageName);
         if (!isRelativeUri(relativeName))
-            throw new IllegalArgumentException("relativeName is invalid");
+            throw new IllegalArgumentException("Invalid relative name: " + relativeName);
         RelativeFile name = packageName.length() == 0
             ? new RelativeFile(relativeName)
             : new RelativeFile(RelativeDirectory.forPackage(packageName), relativeName);
@@ -806,6 +806,8 @@
         String path = uri.normalize().getPath();
         if (path.length() == 0 /* isEmpty() is mustang API */)
             return false;
+        if (!path.equals(uri.getPath())) // implicitly checks for embedded . and ..
+            return false;
         char first = path.charAt(0);
         return first != '.' && first != '/';
     }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Tue Oct 19 16:26:29 2010 +0100
@@ -56,6 +56,8 @@
 import static com.sun.tools.javac.jvm.ClassFile.*;
 import static com.sun.tools.javac.jvm.ClassFile.Version.*;
 
+import static com.sun.tools.javac.main.OptionName.*;
+
 /** This class provides operations to read a classfile into an internal
  *  representation. The internal representation is anchored in a
  *  ClassSymbol which contains in its scope symbol representations
@@ -122,6 +124,9 @@
     /** The symbol table. */
     Symtab syms;
 
+    /** The scope counter */
+    Scope.ScopeCounter scopeCounter;
+
     Types types;
 
     /** The name table. */
@@ -244,6 +249,7 @@
 
         names = Names.instance(context);
         syms = Symtab.instance(context);
+        scopeCounter = Scope.ScopeCounter.instance(context);
         types = Types.instance(context);
         fileManager = context.get(JavaFileManager.class);
         if (fileManager == null)
@@ -255,23 +261,23 @@
 
         Options options = Options.instance(context);
         annotate = Annotate.instance(context);
-        verbose        = options.get("-verbose")        != null;
-        checkClassFile = options.get("-checkclassfile") != null;
+        verbose        = options.isSet(VERBOSE);
+        checkClassFile = options.isSet("-checkclassfile");
         Source source = Source.instance(context);
         allowGenerics    = source.allowGenerics();
         allowVarargs     = source.allowVarargs();
         allowAnnotations = source.allowAnnotations();
-        saveParameterNames = options.get("save-parameter-names") != null;
-        cacheCompletionFailure = options.get("dev") == null;
+        saveParameterNames = options.isSet("save-parameter-names");
+        cacheCompletionFailure = options.isUnset("dev");
         preferSource = "source".equals(options.get("-Xprefer"));
 
         completionFailureName =
-            (options.get("failcomplete") != null)
+            options.isSet("failcomplete")
             ? names.fromString(options.get("failcomplete"))
             : null;
 
         typevars = new Scope(syms.noSymbol);
-        debugJSR308 = options.get("TA:reader") != null;
+        debugJSR308 = options.isSet("TA:reader");
 
         initAttributeReaders();
     }
@@ -1138,12 +1144,6 @@
                 }
             },
 
-            new AttributeReader(names.PolymorphicSignature, V45_3/*S.B.V51*/, CLASS_OR_MEMBER_ATTRIBUTE) {
-                void read(Symbol sym, int attrLen) {
-                    sym.flags_field |= POLYMORPHIC_SIGNATURE;
-                }
-            },
-
 
             // The following attributes for a Code attribute are not currently handled
             // StackMapTable
@@ -1329,6 +1329,9 @@
                     sym.flags_field |= PROPRIETARY;
                 else
                     proxies.append(proxy);
+                if (majorVersion >= V51.major && proxy.type.tsym == syms.polymorphicSignatureType.tsym) {
+                    sym.flags_field |= POLYMORPHIC_SIGNATURE;
+                }
             }
             annotate.later(new AnnotationCompleter(sym, proxies.toList()));
         }
@@ -2030,7 +2033,7 @@
         ClassType ct = (ClassType)c.type;
 
         // allocate scope for members
-        c.members_field = new Scope(c);
+        c.members_field = new Scope.ClassScope(c, scopeCounter);
 
         // prepare type variable table
         typevars = typevars.dup(currentOwner);
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Tue Oct 19 16:26:29 2010 +0100
@@ -34,6 +34,7 @@
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Attribute.RetentionPolicy;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.file.BaseFileObject;
@@ -44,8 +45,10 @@
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.jvm.UninitializedType.*;
+import static com.sun.tools.javac.main.OptionName.*;
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
 
+
 /** This class provides operations to map an internal symbol table graph
  *  rooted in a ClassSymbol into a classfile.
  *
@@ -177,15 +180,16 @@
         types = Types.instance(context);
         fileManager = context.get(JavaFileManager.class);
 
-        debugJSR308    = options.get("TA:writer") != null;
-        verbose        = options.get("-verbose")     != null;
-        scramble       = options.get("-scramble")    != null;
-        scrambleAll    = options.get("-scrambleAll") != null;
-        retrofit       = options.get("-retrofit") != null;
-        genCrt         = options.get("-Xjcov") != null;
-        debugstackmap  = options.get("debugstackmap") != null;
+        debugJSR308    = options.isSet("TA:writer");
+        verbose        = options.isSet(VERBOSE);
+        scramble       = options.isSet("-scramble");
+        scrambleAll    = options.isSet("-scrambleAll");
+        retrofit       = options.isSet("-retrofit");
+        genCrt         = options.isSet(XJCOV);
+        debugstackmap  = options.isSet("debugstackmap");
 
-        emitSourceFile = options.get("-g:")==null || options.get("-g:source")!=null;
+        emitSourceFile = options.isUnset(G_CUSTOM) ||
+                            options.isSet(G_CUSTOM, "source");
 
         String dumpModFlags = options.get("dumpmodifiers");
         dumpClassModifiers =
@@ -682,13 +686,6 @@
             endAttr(alenIdx);
             acount++;
         }
-        if ((flags & POLYMORPHIC_SIGNATURE) != 0) {
-            if (target.majorVersion < 51)
-                throw new AssertionError("PolymorphicSignature attributes in java/dyn must be written with -target 7 (required major version is 51, current is"+target.majorVersion+")");
-            int alenIdx = writeAttr(names.PolymorphicSignature);
-            endAttr(alenIdx);
-            acount++;
-        }
         return acount;
     }
 
@@ -723,7 +720,7 @@
         boolean hasInvisible = false;
         if (m.params != null) for (VarSymbol s : m.params) {
             for (Attribute.Compound a : s.getAnnotationMirrors()) {
-                switch (getRetention(a.type.tsym)) {
+                switch (types.getRetention(a)) {
                 case SOURCE: break;
                 case CLASS: hasInvisible = true; break;
                 case RUNTIME: hasVisible = true; break;
@@ -739,7 +736,7 @@
             for (VarSymbol s : m.params) {
                 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
                 for (Attribute.Compound a : s.getAnnotationMirrors())
-                    if (getRetention(a.type.tsym) == RetentionPolicy.RUNTIME)
+                    if (types.getRetention(a) == RetentionPolicy.RUNTIME)
                         buf.append(a);
                 databuf.appendChar(buf.length());
                 for (Attribute.Compound a : buf)
@@ -754,7 +751,7 @@
             for (VarSymbol s : m.params) {
                 ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
                 for (Attribute.Compound a : s.getAnnotationMirrors())
-                    if (getRetention(a.type.tsym) == RetentionPolicy.CLASS)
+                    if (types.getRetention(a) == RetentionPolicy.CLASS)
                         buf.append(a);
                 databuf.appendChar(buf.length());
                 for (Attribute.Compound a : buf)
@@ -778,7 +775,7 @@
         ListBuffer<Attribute.Compound> visibles = new ListBuffer<Attribute.Compound>();
         ListBuffer<Attribute.Compound> invisibles = new ListBuffer<Attribute.Compound>();
         for (Attribute.Compound a : attrs) {
-            switch (getRetention(a.type.tsym)) {
+            switch (types.getRetention(a)) {
             case SOURCE: break;
             case CLASS: invisibles.append(a); break;
             case RUNTIME: visibles.append(a); break;
@@ -816,7 +813,7 @@
             if (tc.position.type == TargetType.UNKNOWN
                 || !tc.position.emitToClassfile())
                 continue;
-            switch (getRetention(tc.type.tsym)) {
+            switch (types.getRetention(tc)) {
             case SOURCE: break;
             case CLASS: invisibles.append(tc); break;
             case RUNTIME: visibles.append(tc); break;
@@ -846,29 +843,6 @@
         return attrCount;
     }
 
-    /** A mirror of java.lang.annotation.RetentionPolicy. */
-    enum RetentionPolicy {
-        SOURCE,
-        CLASS,
-        RUNTIME
-    }
-
-    RetentionPolicy getRetention(TypeSymbol annotationType) {
-        RetentionPolicy vis = RetentionPolicy.CLASS; // the default
-        Attribute.Compound c = annotationType.attribute(syms.retentionType.tsym);
-        if (c != null) {
-            Attribute value = c.member(names.value);
-            if (value != null && value instanceof Attribute.Enum) {
-                Name levelName = ((Attribute.Enum)value).value.name;
-                if (levelName == names.SOURCE) vis = RetentionPolicy.SOURCE;
-                else if (levelName == names.CLASS) vis = RetentionPolicy.CLASS;
-                else if (levelName == names.RUNTIME) vis = RetentionPolicy.RUNTIME;
-                else ;// /* fail soft */ throw new AssertionError(levelName);
-            }
-        }
-        return vis;
-    }
-
     /** A visitor to write an attribute including its leading
      *  single-character marker.
      */
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Tue Oct 19 16:26:29 2010 +0100
@@ -49,6 +49,7 @@
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.jvm.ByteCodes.*;
 import static com.sun.tools.javac.jvm.CRTFlags.*;
+import static com.sun.tools.javac.main.OptionName.*;
 
 /** This pass maps flat Java (i.e. without inner classes) to bytecodes.
  *
@@ -116,19 +117,19 @@
 
         Options options = Options.instance(context);
         lineDebugInfo =
-            options.get("-g:") == null ||
-            options.get("-g:lines") != null;
+            options.isUnset(G_CUSTOM) ||
+            options.isSet(G_CUSTOM, "lines");
         varDebugInfo =
-            options.get("-g:") == null
-            ? options.get("-g") != null
-            : options.get("-g:vars") != null;
-        genCrt = options.get("-Xjcov") != null;
-        debugCode = options.get("debugcode") != null;
-        allowInvokedynamic = target.hasInvokedynamic() || options.get("invokedynamic") != null;
+            options.isUnset(G_CUSTOM)
+            ? options.isSet(G)
+            : options.isSet(G_CUSTOM, "vars");
+        genCrt = options.isSet(XJCOV);
+        debugCode = options.isSet("debugcode");
+        allowInvokedynamic = target.hasInvokedynamic() || options.isSet("invokedynamic");
 
         generateIproxies =
             target.requiresIproxy() ||
-            options.get("miranda") != null;
+            options.isSet("miranda");
 
         if (target.generateStackMapTable()) {
             // ignore cldc because we cannot have both stackmap formats
@@ -1459,24 +1460,27 @@
                       List<Integer> gaps) {
             if (startpc != endpc) {
                 List<JCExpression> subClauses = TreeInfo.isMultiCatch(tree) ?
-                    ((JCTypeDisjoint)tree.param.vartype).components :
-                    List.of(tree.param.vartype);
-                for (JCExpression subCatch : subClauses) {
-                    int catchType = makeRef(tree.pos(), subCatch.type);
-                    List<Integer> lGaps = gaps;
-                    while (lGaps.nonEmpty()) {
-                        int end = lGaps.head.intValue();
+                        ((JCTypeDisjoint)tree.param.vartype).components :
+                        List.of(tree.param.vartype);
+                while (gaps.nonEmpty()) {
+                    for (JCExpression subCatch : subClauses) {
+                        int catchType = makeRef(tree.pos(), subCatch.type);
+                        int end = gaps.head.intValue();
                         registerCatch(tree.pos(),
                                       startpc,  end, code.curPc(),
                                       catchType);
-                        lGaps = lGaps.tail;
-                        startpc = lGaps.head.intValue();
-                        lGaps = lGaps.tail;
                     }
-                    if (startpc < endpc)
+                    gaps = gaps.tail;
+                    startpc = gaps.head.intValue();
+                    gaps = gaps.tail;
+                }
+                if (startpc < endpc) {
+                    for (JCExpression subCatch : subClauses) {
+                        int catchType = makeRef(tree.pos(), subCatch.type);
                         registerCatch(tree.pos(),
                                       startpc, endpc, code.curPc(),
                                       catchType);
+                    }
                 }
                 VarSymbol exparam = tree.param.sym;
                 code.statBegin(tree.pos);
--- a/src/share/classes/com/sun/tools/javac/jvm/Target.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java	Tue Oct 19 16:26:29 2010 +0100
@@ -31,6 +31,8 @@
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.util.*;
 
+import static com.sun.tools.javac.main.OptionName.*;
+
 /** The classfile version target.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -73,7 +75,7 @@
         Target instance = context.get(targetKey);
         if (instance == null) {
             Options options = Options.instance(context);
-            String targetString = options.get("-target");
+            String targetString = options.get(TARGET);
             if (targetString != null) instance = lookup(targetString);
             if (instance == null) instance = DEFAULT;
             context.put(targetKey, instance);
@@ -262,10 +264,12 @@
         return compareTo(JDK1_7) >= 0;
     }
 
-    /** Does the VM support method handle literals (ldc/CONSTANT_MethodHandle)?
+	/** Does the VM support polymorphic method handle invocation?
+     *  Affects the linkage information output to the classfile.
+     *  An alias for {@code hasInvokedynamic}, since all the JSR 292 features appear together.
      */
-    public boolean hasMethodHandleLiterals() {
-        return compareTo(JDK1_7) >= 0;
+    public boolean hasMethodHandles() {
+        return hasInvokedynamic();
     }
 
     /** Although we may not have support for class literals, should we
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -26,47 +26,44 @@
 package com.sun.tools.javac.main;
 
 import java.io.*;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.MissingResourceException;
+import java.util.Queue;
 import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.logging.Handler;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.annotation.processing.Processor;
+import javax.lang.model.SourceVersion;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.tools.DiagnosticListener;
 
-import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.source.util.TaskEvent;
 import com.sun.source.util.TaskListener;
 
+import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.tree.*;
+import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.parser.*;
 import com.sun.tools.javac.comp.*;
 import com.sun.tools.javac.jvm.*;
-
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
-
 import com.sun.tools.javac.processing.*;
-import javax.annotation.processing.Processor;
 
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
+import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
 import static com.sun.tools.javac.util.ListBuffer.lb;
 
-// TEMP, until we have a more efficient way to save doc comment info
-import com.sun.tools.javac.parser.DocCommentScanner;
-
-import java.util.HashMap;
-import java.util.Queue;
-import javax.lang.model.SourceVersion;
 
 /** This class could be the main entry point for GJC when GJC is used as a
  *  component in a larger software system. It provides operations to
@@ -363,22 +360,22 @@
 
         Options options = Options.instance(context);
 
-        verbose       = options.get("-verbose")       != null;
-        sourceOutput  = options.get("-printsource")   != null; // used to be -s
-        stubOutput    = options.get("-stubs")         != null;
-        relax         = options.get("-relax")         != null;
-        printFlat     = options.get("-printflat")     != null;
-        attrParseOnly = options.get("-attrparseonly") != null;
-        encoding      = options.get("-encoding");
-        lineDebugInfo = options.get("-g:")            == null ||
-                        options.get("-g:lines")       != null;
-        genEndPos     = options.get("-Xjcov")         != null ||
+        verbose       = options.isSet(VERBOSE);
+        sourceOutput  = options.isSet(PRINTSOURCE); // used to be -s
+        stubOutput    = options.isSet("-stubs");
+        relax         = options.isSet("-relax");
+        printFlat     = options.isSet("-printflat");
+        attrParseOnly = options.isSet("-attrparseonly");
+        encoding      = options.get(ENCODING);
+        lineDebugInfo = options.isUnset(G_CUSTOM) ||
+                        options.isSet(G_CUSTOM, "lines");
+        genEndPos     = options.isSet(XJCOV) ||
                         context.get(DiagnosticListener.class) != null;
-        devVerbose    = options.get("dev") != null;
-        processPcks   = options.get("process.packages") != null;
-        werror        = options.get("-Werror")        != null;
+        devVerbose    = options.isSet("dev");
+        processPcks   = options.isSet("process.packages");
+        werror        = options.isSet(WERROR);
 
-        verboseCompilePolicy = options.get("verboseCompilePolicy") != null;
+        verboseCompilePolicy = options.isSet("verboseCompilePolicy");
 
         if (attrParseOnly)
             compilePolicy = CompilePolicy.ATTR_ONLY;
@@ -388,15 +385,15 @@
         implicitSourcePolicy = ImplicitSourcePolicy.decode(options.get("-implicit"));
 
         completionFailureName =
-            (options.get("failcomplete") != null)
+            options.isSet("failcomplete")
             ? names.fromString(options.get("failcomplete"))
             : null;
 
         shouldStopPolicy =
-            (options.get("shouldStopPolicy") != null)
+            options.isSet("shouldStopPolicy")
             ? CompileState.valueOf(options.get("shouldStopPolicy"))
             : null;
-        if (options.get("oldDiags") == null)
+        if (options.isUnset("oldDiags"))
             log.setDiagnosticFormatter(RichDiagnosticFormatter.instance(context));
     }
 
@@ -536,7 +533,7 @@
                 log.error("warnings.and.werror");
             }
         }
-            return log.nerrors;
+        return log.nerrors;
     }
 
     protected final <T> Queue<T> stopIfError(CompileState cs, Queue<T> queue) {
@@ -586,10 +583,8 @@
                 TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, filename);
                 taskListener.started(e);
             }
-            int initialErrorCount = log.nerrors;
             Parser parser = parserFactory.newParser(content, keepComments(), genEndPos, lineDebugInfo);
             tree = parser.parseCompilationUnit();
-            log.unrecoverableError |= (log.nerrors > initialErrorCount);
             if (verbose) {
                 printVerbose("parsing.done", Long.toString(elapsed(msec)));
             }
@@ -615,7 +610,7 @@
      *  @param filename     The name of the file to be parsed.
      */
     @Deprecated
-    public JCTree.JCCompilationUnit parse(String filename) throws IOException {
+    public JCTree.JCCompilationUnit parse(String filename) {
         JavacFileManager fm = (JavacFileManager)fileManager;
         return parse(fm.getJavaFileObjectsFromStrings(List.of(filename)).iterator().next());
     }
@@ -785,7 +780,6 @@
     public void compile(List<JavaFileObject> sourceFileObjects,
                         List<String> classnames,
                         Iterable<? extends Processor> processors)
-        throws IOException // TODO: temp, from JavacProcessingEnvironment
     {
         if (processors != null && processors.iterator().hasNext())
             explicitAnnotationProcessingRequested = true;
@@ -875,14 +869,19 @@
     /**
      * Parses a list of files.
      */
-   public List<JCCompilationUnit> parseFiles(List<JavaFileObject> fileObjects) throws IOException {
+   public List<JCCompilationUnit> parseFiles(Iterable<JavaFileObject> fileObjects) {
        if (shouldStop(CompileState.PARSE))
            return List.nil();
 
         //parse all files
         ListBuffer<JCCompilationUnit> trees = lb();
-        for (JavaFileObject fileObject : fileObjects)
-            trees.append(parse(fileObject));
+        Set<JavaFileObject> filesSoFar = new HashSet<JavaFileObject>();
+        for (JavaFileObject fileObject : fileObjects) {
+            if (!filesSoFar.contains(fileObject)) {
+                filesSoFar.add(fileObject);
+                trees.append(parse(fileObject));
+            }
+        }
         return trees.toList();
     }
 
@@ -923,6 +922,15 @@
             }
             rootClasses = cdefs.toList();
         }
+
+        // Ensure the input files have been recorded. Although this is normally
+        // done by readSource, it may not have been done if the trees were read
+        // in a prior round of annotation processing, and the trees have been
+        // cleaned and are being reused.
+        for (JCCompilationUnit unit : roots) {
+            inputFiles.add(unit.sourcefile);
+        }
+
         return roots;
     }
 
@@ -948,27 +956,24 @@
      * @param processors user provided annotation processors to bypass
      * discovery, {@code null} means that no processors were provided
      */
-    public void initProcessAnnotations(Iterable<? extends Processor> processors)
-                throws IOException {
+    public void initProcessAnnotations(Iterable<? extends Processor> processors) {
         // Process annotations if processing is not disabled and there
         // is at least one Processor available.
         Options options = Options.instance(context);
-        if (options.get("-proc:none") != null) {
+        if (options.isSet(PROC, "none")) {
             processAnnotations = false;
         } else if (procEnvImpl == null) {
             procEnvImpl = new JavacProcessingEnvironment(context, processors);
             processAnnotations = procEnvImpl.atLeastOneProcessor();
 
             if (processAnnotations) {
-                if (context.get(Scanner.Factory.scannerFactoryKey) == null)
-                    DocCommentScanner.Factory.preRegister(context);
                 options.put("save-parameter-names", "save-parameter-names");
                 reader.saveParameterNames = true;
                 keepComments = true;
+                genEndPos = true;
                 if (taskListener != null)
                     taskListener.started(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
-
-
+                log.deferDiagnostics = true;
             } else { // free resources
                 procEnvImpl.close();
             }
@@ -976,8 +981,7 @@
     }
 
     // TODO: called by JavacTaskImpl
-    public JavaCompiler processAnnotations(List<JCCompilationUnit> roots)
-            throws IOException {
+    public JavaCompiler processAnnotations(List<JCCompilationUnit> roots) {
         return processAnnotations(roots, List.<String>nil());
     }
 
@@ -986,17 +990,23 @@
      * @param roots a list of compilation units
      * @return an instance of the compiler in which to complete the compilation
      */
+    // Implementation note: when this method is called, log.deferredDiagnostics
+    // will have been set true by initProcessAnnotations, meaning that any diagnostics
+    // that are reported will go into the log.deferredDiagnostics queue.
+    // By the time this method exits, log.deferDiagnostics must be set back to false,
+    // and all deferredDiagnostics must have been handled: i.e. either reported
+    // or determined to be transient, and therefore suppressed.
     public JavaCompiler processAnnotations(List<JCCompilationUnit> roots,
-                                           List<String> classnames)
-        throws IOException  { // TODO: see TEMP note in JavacProcessingEnvironment
+                                           List<String> classnames) {
         if (shouldStop(CompileState.PROCESS)) {
-            // Errors were encountered.  If todo is empty, then the
-            // encountered errors were parse errors.  Otherwise, the
-            // errors were found during the enter phase which should
-            // be ignored when processing annotations.
-
-            if (todo.isEmpty())
+            // Errors were encountered.
+            // Unless all the errors are resolve errors, the errors were parse errors
+            // or other errors during enter which cannot be fixed by running
+            // any annotation processors.
+            if (unrecoverableError()) {
+                log.reportDeferredDiagnostics();
                 return this;
+            }
         }
 
         // ASSERT: processAnnotations and procEnvImpl should have been set up by
@@ -1009,7 +1019,7 @@
             // annotation processing is to occur with compilation,
             // emit a warning.
             Options options = Options.instance(context);
-            if (options.get("-proc:only") != null) {
+            if (options.isSet(PROC, "only")) {
                 log.warning("proc.proc-only.requested.no.procs");
                 todo.clear();
             }
@@ -1018,6 +1028,7 @@
                 log.error("proc.no.explicit.annotation.processing.requested",
                           classnames);
             }
+            log.reportDeferredDiagnostics();
             return this; // continue regular compilation
         }
 
@@ -1030,6 +1041,7 @@
                 if (!explicitAnnotationProcessingRequested()) {
                     log.error("proc.no.explicit.annotation.processing.requested",
                               classnames);
+                    log.reportDeferredDiagnostics();
                     return this; // TODO: Will this halt compilation?
                 } else {
                     boolean errors = false;
@@ -1044,7 +1056,6 @@
                             if (sym.kind == Kinds.PCK)
                                 sym.complete();
                             if (sym.exists()) {
-                                Name name = names.fromString(nameStr);
                                 if (sym.kind == Kinds.PCK)
                                     pckSymbols = pckSymbols.prepend((PackageSymbol)sym);
                                 else
@@ -1060,33 +1071,46 @@
                             continue;
                         }
                     }
-                    if (errors)
+                    if (errors) {
+                        log.reportDeferredDiagnostics();
                         return this;
+                    }
                 }
             }
             try {
                 JavaCompiler c = procEnvImpl.doProcessing(context, roots, classSymbols, pckSymbols);
                 if (c != this)
                     annotationProcessingOccurred = c.annotationProcessingOccurred = true;
+                // doProcessing will have handled deferred diagnostics
+                assert c.log.deferDiagnostics == false;
+                assert c.log.deferredDiagnostics.size() == 0;
                 return c;
             } finally {
                 procEnvImpl.close();
             }
         } catch (CompletionFailure ex) {
             log.error("cant.access", ex.sym, ex.getDetailValue());
+            log.reportDeferredDiagnostics();
             return this;
+        }
+    }
 
+    private boolean unrecoverableError() {
+        for (JCDiagnostic d: log.deferredDiagnostics) {
+            if (d.getKind() == JCDiagnostic.Kind.ERROR && !d.isFlagSet(RESOLVE_ERROR))
+                return true;
         }
+        return false;
     }
 
     boolean explicitAnnotationProcessingRequested() {
         Options options = Options.instance(context);
         return
             explicitAnnotationProcessingRequested ||
-            options.get("-processor") != null ||
-            options.get("-processorpath") != null ||
-            options.get("-proc:only") != null ||
-            options.get("-Xprint") != null;
+            options.isSet(PROCESSOR) ||
+            options.isSet(PROCESSORPATH) ||
+            options.isSet(PROC, "only") ||
+            options.isSet(XPRINT);
     }
 
     /**
@@ -1127,6 +1151,11 @@
                                   env.toplevel.sourcefile);
         try {
             attr.attribClass(env.tree.pos(), env.enclClass.sym);
+            if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
+                //if in fail-over mode, ensure that AST expression nodes
+                //are correctly initialized (e.g. they have a type/symbol)
+                attr.postAttr(env);
+            }
             compileStates.put(env, CompileState.ATTR);
         }
         finally {
@@ -1559,6 +1588,7 @@
     }
 
     public void initRound(JavaCompiler prev) {
+        genEndPos = prev.genEndPos;
         keepComments = prev.keepComments;
         start_msec = prev.start_msec;
         hasBeenUsed = true;
--- a/src/share/classes/com/sun/tools/javac/main/Main.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Tue Oct 19 16:26:29 2010 +0100
@@ -32,6 +32,9 @@
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
 import java.util.MissingResourceException;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import javax.annotation.processing.Processor;
 
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.file.CacheFSInfo;
@@ -41,9 +44,8 @@
 import com.sun.tools.javac.main.RecognizedOptions.OptionHelper;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.processing.AnnotationProcessingError;
-import javax.tools.JavaFileManager;
-import javax.tools.JavaFileObject;
-import javax.annotation.processing.Processor;
+
+import static com.sun.tools.javac.main.OptionName.*;
 
 /** This class provides a commandline interface to the GJC compiler.
  *
@@ -239,16 +241,16 @@
             }
         }
 
-        if (!checkDirectory("-d"))
+        if (!checkDirectory(D))
             return null;
-        if (!checkDirectory("-s"))
+        if (!checkDirectory(S))
             return null;
 
-        String sourceString = options.get("-source");
+        String sourceString = options.get(SOURCE);
         Source source = (sourceString != null)
             ? Source.lookup(sourceString)
             : Source.DEFAULT;
-        String targetString = options.get("-target");
+        String targetString = options.get(TARGET);
         Target target = (targetString != null)
             ? Target.lookup(targetString)
             : Target.DEFAULT;
@@ -282,6 +284,13 @@
             }
         }
 
+        // phase this out with JSR 292 PFD
+        if ("no".equals(options.get("allowTransitionalJSR292"))) {
+            options.put("allowTransitionalJSR292", null);
+        } else if (target.hasInvokedynamic() && options.isUnset("allowTransitionalJSR292")) {
+            options.put("allowTransitionalJSR292", "allowTransitionalJSR292");
+        }
+
         // handle this here so it works even if no other options given
         String showClass = options.get("showClass");
         if (showClass != null) {
@@ -293,7 +302,7 @@
         return filenames.toList();
     }
     // where
-        private boolean checkDirectory(String optName) {
+        private boolean checkDirectory(OptionName optName) {
             String value = options.get(optName);
             if (value == null)
                 return true;
@@ -360,10 +369,10 @@
                     return EXIT_CMDERR;
                 } else if (files.isEmpty() && fileObjects.isEmpty() && classnames.isEmpty()) {
                     // it is allowed to compile nothing if just asking for help or version info
-                    if (options.get("-help") != null
-                        || options.get("-X") != null
-                        || options.get("-version") != null
-                        || options.get("-fullversion") != null)
+                    if (options.isSet(HELP)
+                        || options.isSet(X)
+                        || options.isSet(VERSION)
+                        || options.isSet(FULLVERSION))
                         return EXIT_OK;
                     error("err.no.source.files");
                     return EXIT_CMDERR;
@@ -375,7 +384,7 @@
                 return EXIT_SYSERR;
             }
 
-            boolean forceStdOut = options.get("stdout") != null;
+            boolean forceStdOut = options.isSet("stdout");
             if (forceStdOut) {
                 out.flush();
                 out = new PrintWriter(System.out, true);
@@ -384,7 +393,7 @@
             context.put(Log.outKey, out);
 
             // allow System property in following line as a Mustang legacy
-            boolean batchMode = (options.get("nonBatchMode") == null
+            boolean batchMode = (options.isUnset("nonBatchMode")
                         && System.getProperty("nonBatchMode") == null);
             if (batchMode)
                 CacheFSInfo.preRegister(context);
@@ -448,7 +457,7 @@
             // for buggy compiler error recovery by swallowing thrown
             // exceptions.
             if (comp == null || comp.errorCount() == 0 ||
-                options == null || options.get("dev") != null)
+                options == null || options.isSet("dev"))
                 bugMessage(ex);
             return EXIT_ABNORMAL;
         } finally {
@@ -467,10 +476,13 @@
         ex.printStackTrace(out);
     }
 
-    /** Print a message reporting an fatal error.
+    /** Print a message reporting a fatal error.
      */
     void feMessage(Throwable ex) {
         Log.printLines(out, ex.getMessage());
+        if (ex.getCause() != null && options.isSet("dev")) {
+            ex.getCause().printStackTrace(out);
+        }
     }
 
     /** Print a message reporting an input/output error.
--- a/src/share/classes/com/sun/tools/javac/main/OptionName.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/OptionName.java	Tue Oct 19 16:26:29 2010 +0100
@@ -80,6 +80,7 @@
     XMAXERRS("-Xmaxerrs"),
     XMAXWARNS("-Xmaxwarns"),
     XSTDOUT("-Xstdout"),
+    XPKGINFO("-Xpkginfo:"),
     XPRINT("-Xprint"),
     XPRINTROUNDS("-XprintRounds"),
     XPRINTPROCESSORINFO("-XprintProcessorInfo"),
--- a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Tue Oct 19 16:26:29 2010 +0100
@@ -160,6 +160,7 @@
         XMAXERRS,
         XMAXWARNS,
         XSTDOUT,
+        XPKGINFO,
         XPRINT,
         XPRINTROUNDS,
         XPRINTPROCESSORINFO,
@@ -217,6 +218,7 @@
         XMAXERRS,
         XMAXWARNS,
         // XSTDOUT,
+        XPKGINFO,
         XPRINT,
         XPRINTROUNDS,
         XPRINTPROCESSORINFO,
@@ -532,6 +534,9 @@
         new XOption(XPREFER,                                    "opt.prefer",
                 Option.ChoiceKind.ONEOF, "source", "newer"),
 
+        new XOption(XPKGINFO,                                   "opt.pkginfo",
+                Option.ChoiceKind.ONEOF, "always", "legacy", "nonempty"),
+
         /* -O is a no-op, accepted for backward compatibility. */
         new HiddenOption(O),
 
@@ -598,6 +603,16 @@
     };
     }
 
+    public enum PkgInfo {
+        ALWAYS, LEGACY, NONEMPTY;
+        public static PkgInfo get(Options options) {
+            String v = options.get(XPKGINFO);
+            return (v == null
+                    ? PkgInfo.LEGACY
+                    : PkgInfo.valueOf(v.toUpperCase()));
+        }
+    }
+
     private static Map<String,Boolean> getXLintChoices() {
         Map<String,Boolean> choices = new LinkedHashMap<String,Boolean>();
         choices.put("all", false);
--- a/src/share/classes/com/sun/tools/javac/model/JavacTypes.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/JavacTypes.java	Tue Oct 19 16:26:29 2010 +0100
@@ -103,7 +103,7 @@
     public boolean contains(TypeMirror t1, TypeMirror t2) {
         validateTypeNotIn(t1, EXEC_OR_PKG);
         validateTypeNotIn(t2, EXEC_OR_PKG);
-        return ((Type) t1).contains((Type) t2);
+        return types.containsType((Type) t1, (Type) t2);
     }
 
     public boolean isSubsignature(ExecutableType m1, ExecutableType m2) {
--- a/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Tue Oct 19 16:26:29 2010 +0100
@@ -366,11 +366,11 @@
 //            }
 //        }
         int maxDepth = (recurse ? Integer.MAX_VALUE : 1);
-        Set<FileVisitOption> opts = EnumSet.of(DETECT_CYCLES, FOLLOW_LINKS);
+        Set<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS);
         Files.walkFileTree(packageDir, opts, maxDepth,
                 new SimpleFileVisitor<Path>() {
             @Override
-            public FileVisitResult preVisitDirectory(Path dir) {
+            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
                 if (SourceVersion.isIdentifier(dir.getName().toString())) // JSR 292?
                     return FileVisitResult.CONTINUE;
                 else
--- a/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,50 +42,17 @@
  */
 public class DocCommentScanner extends Scanner {
 
-    /** A factory for creating scanners. */
-    public static class Factory extends Scanner.Factory {
-
-        public static void preRegister(final Context context) {
-            context.put(scannerFactoryKey, new Context.Factory<Scanner.Factory>() {
-                public Factory make() {
-                    return new Factory(context);
-                }
-            });
-        }
-
-        /** Create a new scanner factory. */
-        protected Factory(Context context) {
-            super(context);
-        }
-
-        @Override
-        public Scanner newScanner(CharSequence input) {
-            if (input instanceof CharBuffer) {
-                return new DocCommentScanner(this, (CharBuffer)input);
-            } else {
-                char[] array = input.toString().toCharArray();
-                return newScanner(array, array.length);
-            }
-        }
-
-        @Override
-        public Scanner newScanner(char[] input, int inputLength) {
-            return new DocCommentScanner(this, input, inputLength);
-        }
-    }
-
-
     /** Create a scanner from the input buffer.  buffer must implement
      *  array() and compact(), and remaining() must be less than limit().
      */
-    protected DocCommentScanner(Factory fac, CharBuffer buffer) {
+    protected DocCommentScanner(ScannerFactory fac, CharBuffer buffer) {
         super(fac, buffer);
     }
 
     /** Create a scanner from the input array.  The array must have at
      *  least a single character of extra space.
      */
-    protected DocCommentScanner(Factory fac, char[] input, int inputLength) {
+    protected DocCommentScanner(ScannerFactory fac, char[] input, int inputLength) {
         super(fac, input, inputLength);
     }
 
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -2811,6 +2811,11 @@
                 defs.append(importDeclaration());
             } else {
                 JCTree def = typeDeclaration(mods);
+                if (keepDocComments && dc != null && docComments.get(def) == dc) {
+                    // If the first type declaration has consumed the first doc
+                    // comment, then don't use it for the top level comment as well.
+                    dc = null;
+                }
                 if (def instanceof JCExpressionStatement)
                     def = ((JCExpressionStatement)def).expr;
                 defs.append(def);
@@ -3123,7 +3128,7 @@
     List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface) {
         if (S.token() == SEMI) {
             S.nextToken();
-            return List.<JCTree>of(F.at(Position.NOPOS).Block(0, List.<JCStatement>nil()));
+            return List.<JCTree>nil();
         } else {
             boolean isExtension = false;
             String dc = S.docComment();
--- a/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -59,7 +59,7 @@
     final Source source;
     final Names names;
     final Options options;
-    final Scanner.Factory scannerFactory;
+    final ScannerFactory scannerFactory;
 
     protected ParserFactory(Context context) {
         super();
@@ -70,11 +70,11 @@
         this.keywords = Keywords.instance(context);
         this.source = Source.instance(context);
         this.options = Options.instance(context);
-        this.scannerFactory = Scanner.Factory.instance(context);
+        this.scannerFactory = ScannerFactory.instance(context);
     }
 
     public Parser newParser(CharSequence input, boolean keepDocComments, boolean keepEndPos, boolean keepLineMap) {
-        Lexer lexer = scannerFactory.newScanner(input);
+        Lexer lexer = scannerFactory.newScanner(input, keepDocComments);
         if (keepEndPos) {
             return new EndPosParser(this, lexer, keepDocComments, keepLineMap);
         } else {
--- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Tue Oct 19 16:26:29 2010 +0100
@@ -46,51 +46,6 @@
 public class Scanner implements Lexer {
 
     private static boolean scannerDebug = false;
-
-    /** A factory for creating scanners. */
-    public static class Factory {
-        /** The context key for the scanner factory. */
-        public static final Context.Key<Scanner.Factory> scannerFactoryKey =
-            new Context.Key<Scanner.Factory>();
-
-        /** Get the Factory instance for this context. */
-        public static Factory instance(Context context) {
-            Factory instance = context.get(scannerFactoryKey);
-            if (instance == null)
-                instance = new Factory(context);
-            return instance;
-        }
-
-        final Log log;
-        final Names names;
-        final Source source;
-        final Keywords keywords;
-        final Options options;
-
-        /** Create a new scanner factory. */
-        protected Factory(Context context) {
-            context.put(scannerFactoryKey, this);
-            this.log = Log.instance(context);
-            this.names = Names.instance(context);
-            this.source = Source.instance(context);
-            this.keywords = Keywords.instance(context);
-            this.options = Options.instance(context);
-        }
-
-        public Scanner newScanner(CharSequence input) {
-            if (input instanceof CharBuffer) {
-                return new Scanner(this, (CharBuffer)input);
-            } else {
-                char[] array = input.toString().toCharArray();
-                return newScanner(array, array.length);
-            }
-        }
-
-        public Scanner newScanner(char[] input, int inputLength) {
-            return new Scanner(this, input, inputLength);
-        }
-    }
-
     /* Output variables; set by nextToken():
      */
 
@@ -110,6 +65,11 @@
      */
     private boolean allowUnderscoresInLiterals;
 
+	/** Allow exotic identifiers.
+     */
+    private boolean allowExoticIdentifiers;
+
+
     /** Give experimental assist to JSR 292 "ldc CONSTANT_MethodHandle".
      *  Note: this code should be removed from the final version
      */
@@ -247,7 +207,7 @@
     private final Keywords keywords;
 
     /** Common code for constructors. */
-    private Scanner(Factory fac) {
+    private Scanner(ScannerFactory fac) {
         log = fac.log;
         names = fac.names;
         keywords = fac.keywords;
@@ -256,6 +216,7 @@
         allowHexFloats = source.allowHexFloats();
         allowUnderscoresInLiterals = source.allowBinaryLiterals();
         allowMethodReferences = source.allowMethodReferences();
+        allowExoticIdentifiers = source.allowExoticIdentifiers();  // for invokedynamic
         stateStack = List.of(new ScannerState());
     }
 
@@ -287,7 +248,7 @@
     /** Create a scanner from the input buffer.  buffer must implement
      *  array() and compact(), and remaining() must be less than limit().
      */
-    protected Scanner(Factory fac, CharBuffer buffer) {
+    protected Scanner(ScannerFactory fac, CharBuffer buffer) {
         this(fac, JavacFileManager.toArray(buffer), buffer.limit());
     }
 
@@ -302,7 +263,7 @@
      * @param inputLength the size of the input.
      * Must be positive and less than or equal to input.length.
      */
-    protected Scanner(Factory fac, char[] input, int inputLength) {
+    protected Scanner(ScannerFactory fac, char[] input, int inputLength) {
         this(fac);
         eofPos = inputLength;
         if (inputLength == input.length) {
@@ -1119,6 +1080,10 @@
                 case '#':
                     scanChar();
                     if (ch == '\"') {
+                        if (!allowExoticIdentifiers) {
+                            lexError("unsupported.exotic.id", source.name);
+                            allowExoticIdentifiers = true;
+                        }
                         scanChar();
                         if (ch == '\"')
                             lexError(pos, "empty.bytecode.ident");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/parser/ScannerFactory.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.parser;
+
+import java.nio.CharBuffer;
+
+import com.sun.tools.javac.code.Source;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Names;
+
+
+/**
+ * A factory for creating scanners.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends 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 ScannerFactory {
+    /** The context key for the scanner factory. */
+    public static final Context.Key<ScannerFactory> scannerFactoryKey =
+        new Context.Key<ScannerFactory>();
+
+    /** Get the Factory instance for this context. */
+    public static ScannerFactory instance(Context context) {
+        ScannerFactory instance = context.get(scannerFactoryKey);
+        if (instance == null)
+            instance = new ScannerFactory(context);
+        return instance;
+    }
+
+    final Log log;
+    final Names names;
+    final Source source;
+    final Keywords keywords;
+
+    /** Create a new scanner factory. */
+    protected ScannerFactory(Context context) {
+        context.put(scannerFactoryKey, this);
+        this.log = Log.instance(context);
+        this.names = Names.instance(context);
+        this.source = Source.instance(context);
+        this.keywords = Keywords.instance(context);
+    }
+
+    public Scanner newScanner(CharSequence input, boolean keepDocComments) {
+        if (input instanceof CharBuffer) {
+            CharBuffer buf = (CharBuffer) input;
+            if (keepDocComments)
+                return new DocCommentScanner(this, buf);
+            else
+                return new Scanner(this, buf);
+        } else {
+            char[] array = input.toString().toCharArray();
+            return newScanner(array, array.length, keepDocComments);
+        }
+    }
+
+    public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
+        if (keepDocComments)
+            return new DocCommentScanner(this, input, inputLength);
+        else
+            return new Scanner(this, input, inputLength);
+    }
+}
--- a/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Tue Oct 19 16:26:29 2010 +0100
@@ -25,15 +25,8 @@
 
 package com.sun.tools.javac.processing;
 
-import com.sun.tools.javac.util.*;
-import javax.annotation.processing.*;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.NestingKind;
-import javax.lang.model.element.Modifier;
-import javax.lang.model.element.Element;
-import java.util.*;
-
 import java.io.Closeable;
+import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.FilterOutputStream;
@@ -42,14 +35,26 @@
 import java.io.FilterWriter;
 import java.io.PrintWriter;
 import java.io.IOException;
+import java.util.*;
 
-import javax.tools.*;
 import static java.util.Collections.*;
 
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.NestingKind;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.Element;
+import javax.tools.*;
 import javax.tools.JavaFileManager.Location;
+
 import static javax.tools.StandardLocation.SOURCE_OUTPUT;
 import static javax.tools.StandardLocation.CLASS_OUTPUT;
 
+import com.sun.tools.javac.code.Lint;
+import com.sun.tools.javac.util.*;
+
+import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
+
 /**
  * The FilerImplementation class must maintain a number of
  * constraints.  First, multiple attempts to open the same path within
@@ -365,7 +370,7 @@
         aggregateGeneratedSourceNames = new LinkedHashSet<String>();
         aggregateGeneratedClassNames  = new LinkedHashSet<String>();
 
-        lint = (Options.instance(context)).lint("processing");
+        lint = (Lint.instance(context)).isEnabled(PROCESSING);
     }
 
     public JavaFileObject createSourceFile(CharSequence name,
@@ -450,10 +455,15 @@
         // TODO: Only support reading resources in selected output
         // locations?  Only allow reading of non-source, non-class
         // files from the supported input locations?
-        FileObject fileObject = fileManager.getFileForOutput(location,
-                                                             pkg.toString(),
-                                                             relativeName.toString(),
-                                                             null);
+        FileObject fileObject = fileManager.getFileForInput(location,
+                    pkg.toString(),
+                    relativeName.toString());
+        if (fileObject == null) {
+            String name = (pkg.length() == 0)
+                    ? relativeName.toString() : (pkg + "/" + relativeName);
+            throw new FileNotFoundException(name);
+        }
+
         // If the path was already opened for writing, throw an exception.
         checkFileReopening(fileObject, false);
         return new FilerInputFileObject(fileObject);
--- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -49,6 +49,7 @@
 import javax.tools.JavaFileObject;
 import javax.tools.DiagnosticListener;
 
+import com.sun.tools.javac.api.JavacTrees;
 import com.sun.source.util.AbstractTypeProcessor;
 import com.sun.source.util.TaskEvent;
 import com.sun.source.util.TaskListener;
@@ -67,6 +68,8 @@
 import com.sun.tools.javac.util.Abort;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Convert;
+import com.sun.tools.javac.util.FatalError;
+import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Log;
 import com.sun.tools.javac.util.JavacMessages;
@@ -75,6 +78,9 @@
 import com.sun.tools.javac.util.Options;
 
 import static javax.tools.StandardLocation.*;
+import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
+import static com.sun.tools.javac.main.OptionName.*;
+import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING;
 
 /**
  * Objects of this class hold and manage the state needed to support
@@ -95,6 +101,7 @@
     private final boolean procOnly;
     private final boolean fatalErrors;
     private final boolean werror;
+    private final boolean showResolveErrors;
     private boolean foundTypeProcessors;
 
     private final JavacFiler filer;
@@ -131,6 +138,10 @@
      */
     Log log;
 
+    /** Diagnostic factory.
+     */
+    JCDiagnostic.Factory diags;
+
     /**
      * Source level of the compile.
      */
@@ -146,18 +157,19 @@
     private Context context;
 
     public JavacProcessingEnvironment(Context context, Iterable<? extends Processor> processors) {
-        options = Options.instance(context);
         this.context = context;
         log = Log.instance(context);
         source = Source.instance(context);
-        printProcessorInfo = options.get("-XprintProcessorInfo") != null;
-        printRounds = options.get("-XprintRounds") != null;
-        verbose = options.get("-verbose") != null;
-        lint = options.lint("processing");
-        procOnly = options.get("-proc:only") != null ||
-            options.get("-Xprint") != null;
-        fatalErrors = options.get("fatalEnterError") != null;
-        werror = options.get("-Werror") != null;
+        diags = JCDiagnostic.Factory.instance(context);
+        options = Options.instance(context);
+        printProcessorInfo = options.isSet(XPRINTPROCESSORINFO);
+        printRounds = options.isSet(XPRINTROUNDS);
+        verbose = options.isSet(VERBOSE);
+        lint = Lint.instance(context).isEnabled(PROCESSING);
+        procOnly = options.isSet(PROC, "only") || options.isSet(XPRINT);
+        fatalErrors = options.isSet("fatalEnterError");
+        showResolveErrors = options.isSet("showResolveErrors");
+        werror = options.isSet(WERROR);
         platformAnnotations = initPlatformAnnotations();
         foundTypeProcessors = false;
 
@@ -189,7 +201,7 @@
         Log   log   = Log.instance(context);
         Iterator<? extends Processor> processorIterator;
 
-        if (options.get("-Xprint") != null) {
+        if (options.isSet(XPRINT)) {
             try {
                 Processor processor = PrintingProcessor.class.newInstance();
                 processorIterator = List.of(processor).iterator();
@@ -202,7 +214,7 @@
         } else if (processors != null) {
             processorIterator = processors.iterator();
         } else {
-            String processorNames = options.get("-processor");
+            String processorNames = options.get(PROCESSOR);
             JavaFileManager fileManager = context.get(JavaFileManager.class);
             try {
                 // If processorpath is not explicitly set, use the classpath.
@@ -253,7 +265,7 @@
                 ? standardFileManager.getLocation(ANNOTATION_PROCESSOR_PATH)
                 : standardFileManager.getLocation(CLASS_PATH);
 
-            if (needClassLoader(options.get("-processor"), workingPath) )
+            if (needClassLoader(options.get(PROCESSOR), workingPath) )
                 handleException(key, e);
 
         } else {
@@ -734,7 +746,7 @@
         psi.runContributingProcs(renv);
 
         // Debugging
-        if (options.get("displayFilerState") != null)
+        if (options.isSet("displayFilerState"))
             filer.displayState();
     }
 
@@ -795,6 +807,13 @@
         final JavaCompiler compiler;
         /** The log for the round. */
         final Log log;
+        /** The number of warnings in the previous round. */
+        final int priorWarnings;
+
+        /** The ASTs to be compiled. */
+        List<JCCompilationUnit> roots;
+        /** The classes to be compiler that have were generated. */
+        Map<String, JavaFileObject> genClassFiles;
 
         /** The set of annotations to be processed this round. */
         Set<TypeElement> annotationsPresent;
@@ -803,26 +822,98 @@
         /** The set of package-info files to be processed this round. */
         List<PackageSymbol> packageInfoFiles;
 
-        /** Create a round. */
-        Round(Context context, int number) {
+        /** Create a round (common code). */
+        private Round(Context context, int number, int priorWarnings) {
             this.context = context;
             this.number = number;
+            this.priorWarnings = priorWarnings;
+
             compiler = JavaCompiler.instance(context);
             log = Log.instance(context);
+            log.deferDiagnostics = true;
 
             // the following is for the benefit of JavacProcessingEnvironment.getContext()
             JavacProcessingEnvironment.this.context = context;
 
             // the following will be populated as needed
-            annotationsPresent = new LinkedHashSet<TypeElement>();
             topLevelClasses  = List.nil();
             packageInfoFiles = List.nil();
         }
 
+        /** Create the first round. */
+        Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols) {
+            this(context, 1, 0);
+            this.roots = roots;
+            genClassFiles = new HashMap<String,JavaFileObject>();
+
+            compiler.todo.clear(); // free the compiler's resources
+
+            // The reverse() in the following line is to maintain behavioural
+            // compatibility with the previous revision of the code. Strictly speaking,
+            // it should not be necessary, but a javah golden file test fails without it.
+            topLevelClasses =
+                getTopLevelClasses(roots).prependList(classSymbols.reverse());
+
+            packageInfoFiles = getPackageInfoFiles(roots);
+
+            findAnnotationsPresent();
+        }
+
+        /** Create a new round. */
+        private Round(Round prev,
+                Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
+            this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings);
+            this.genClassFiles = prev.genClassFiles;
+
+            updateProcessingState();
+
+            List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
+            roots = cleanTrees(prev.roots).appendList(parsedFiles);
+
+            // Check for errors after parsing
+            if (unrecoverableError())
+                return;
+
+            enterClassFiles(genClassFiles);
+            List<ClassSymbol> newClasses = enterClassFiles(newClassFiles);
+            genClassFiles.putAll(newClassFiles);
+            enterTrees(roots);
+
+            if (unrecoverableError())
+                return;
+
+            topLevelClasses = join(
+                    getTopLevelClasses(parsedFiles),
+                    getTopLevelClassesFromClasses(newClasses));
+
+            packageInfoFiles = join(
+                    getPackageInfoFiles(parsedFiles),
+                    getPackageInfoFilesFromClasses(newClasses));
+
+            findAnnotationsPresent();
+        }
+
         /** Create the next round to be used. */
-        Round next() {
-            compiler.close(false);
-            return new Round(contextForNextRound(), number + 1);
+        Round next(Set<JavaFileObject> newSourceFiles, Map<String, JavaFileObject> newClassFiles) {
+            try {
+                return new Round(this, newSourceFiles, newClassFiles);
+            } finally {
+                compiler.close(false);
+            }
+        }
+
+        /** Create the compiler to be used for the final compilation. */
+        JavaCompiler finalCompiler(boolean errorStatus) {
+            try {
+                JavaCompiler c = JavaCompiler.instance(nextContext());
+                if (errorStatus) {
+                    c.log.nwarnings += priorWarnings + compiler.log.nwarnings;
+                    c.log.nerrors += compiler.log.nerrors;
+                }
+                return c;
+            } finally {
+                compiler.close(false);
+            }
         }
 
         /** Return the number of errors found so far in this round.
@@ -839,12 +930,30 @@
 
         /** Return whether or not an unrecoverable error has occurred. */
         boolean unrecoverableError() {
-            return log.unrecoverableError;
+            if (messager.errorRaised())
+                return true;
+
+            for (JCDiagnostic d: log.deferredDiagnostics) {
+                switch (d.getKind()) {
+                    case WARNING:
+                        if (werror)
+                            return true;
+                        break;
+
+                    case ERROR:
+                        if (fatalErrors || !d.isFlagSet(RESOLVE_ERROR))
+                            return true;
+                        break;
+                }
+            }
+
+            return false;
         }
 
         /** Find the set of annotations present in the set of top level
-         * classes and package info files to be processed this round. */
-        void findAnnotationsPresent(ComputeAnnotationSet annotationComputer) {
+         *  classes and package info files to be processed this round. */
+        void findAnnotationsPresent() {
+            ComputeAnnotationSet annotationComputer = new ComputeAnnotationSet(elementUtils);
             // Use annotation processing to compute the set of annotations present
             annotationsPresent = new LinkedHashSet<TypeElement>();
             for (ClassSymbol classSym : topLevelClasses)
@@ -853,26 +962,13 @@
                 annotationComputer.scan(pkgSym, annotationsPresent);
         }
 
-        /**
-         * Parse the latest set of generated source files created by the filer.
-         */
-        List<JCCompilationUnit> parseNewSourceFiles()
-            throws IOException {
-            List<JavaFileObject> fileObjects = List.nil();
-            for (JavaFileObject jfo : filer.getGeneratedSourceFileObjects() ) {
-                fileObjects = fileObjects.prepend(jfo);
-            }
-
-           return compiler.parseFiles(fileObjects);
-        }
-
-        /** Enter the latest set of generated class files created by the filer. */
-        List<ClassSymbol> enterNewClassFiles() {
+        /** Enter a set of generated class files. */
+        private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
             ClassReader reader = ClassReader.instance(context);
             Names names = Names.instance(context);
             List<ClassSymbol> list = List.nil();
 
-            for (Map.Entry<String,JavaFileObject> entry : filer.getGeneratedClasses().entrySet()) {
+            for (Map.Entry<String,JavaFileObject> entry : classFiles.entrySet()) {
                 Name name = names.fromString(entry.getKey());
                 JavaFileObject file = entry.getValue();
                 if (file.getKind() != JavaFileObject.Kind.CLASS)
@@ -894,17 +990,13 @@
         }
 
         /** Enter a set of syntax trees. */
-        void enterTrees(List<JCCompilationUnit> roots) {
+        private void enterTrees(List<JCCompilationUnit> roots) {
             compiler.enterTrees(roots);
         }
 
         /** Run a processing round. */
         void run(boolean lastRound, boolean errorStatus) {
-//            assert lastRound
-//                ? (topLevelClasses.size() == 0 && annotationsPresent.size() == 0)
-//                : (errorStatus == false);
-//
-//            printRoundInfo(topLevelClasses, annotationsPresent, lastRound);
+            printRoundInfo(lastRound);
 
             TaskListener taskListener = context.get(TaskListener.class);
             if (taskListener != null)
@@ -912,7 +1004,6 @@
 
             try {
                 if (lastRound) {
-                    printRoundInfo(List.<ClassSymbol>nil(), Collections.<TypeElement>emptySet(), lastRound);
                     filer.setLastRound(true);
                     Set<Element> emptyRootElements = Collections.emptySet(); // immutable
                     RoundEnvironment renv = new JavacRoundEnvironment(true,
@@ -921,7 +1012,6 @@
                             JavacProcessingEnvironment.this);
                     discoveredProcs.iterator().runContributingProcs(renv);
                 } else {
-                    printRoundInfo(topLevelClasses, annotationsPresent, lastRound);
                     discoverAndRunProcs(context, annotationsPresent, topLevelClasses, packageInfoFiles);
                 }
             } finally {
@@ -930,12 +1020,17 @@
             }
         }
 
+        void showDiagnostics(boolean showAll) {
+            Set<JCDiagnostic.Kind> kinds = EnumSet.allOf(JCDiagnostic.Kind.class);
+            if (!showAll) {
+                // suppress errors, which are all presumed to be transient resolve errors
+                kinds.remove(JCDiagnostic.Kind.ERROR);
+            }
+            log.reportDeferredDiagnostics(kinds);
+        }
+
         /** Update the processing state for the current context. */
-        // Question: should this not be part of next()?
-        // Note: Calling it from next() breaks some tests. There is an issue
-        // whether the annotationComputer is using elementUtils with the
-        // correct context.
-        void updateProcessingState() {
+        private void updateProcessingState() {
             filer.newRound(context);
             messager.newRound(context);
 
@@ -944,14 +1039,14 @@
         }
 
         /** Print info about this round. */
-        private void printRoundInfo(List<ClassSymbol> topLevelClasses,
-                Set<TypeElement> annotationsPresent,
-                boolean lastRound) {
+        private void printRoundInfo(boolean lastRound) {
             if (printRounds || verbose) {
+                List<ClassSymbol> tlc = lastRound ? List.<ClassSymbol>nil() : topLevelClasses;
+                Set<TypeElement> ap = lastRound ? Collections.<TypeElement>emptySet() : annotationsPresent;
                 log.printNoteLines("x.print.rounds",
-                        (!lastRound ? number : number + 1),
-                        "{" + topLevelClasses.toString(", ") + "}",
-                        annotationsPresent,
+                        number,
+                        "{" + tlc.toString(", ") + "}",
+                        ap,
                         lastRound);
             }
         }
@@ -960,7 +1055,7 @@
          * Important values are propogated from round to round;
          * other values are implicitly reset.
          */
-        private Context contextForNextRound() {
+        private Context nextContext() {
             Context next = new Context();
 
             Options options = Options.instance(context);
@@ -1011,6 +1106,12 @@
                 task.updateContext(next);
             }
 
+            JavacTrees trees = context.get(JavacTrees.class);
+            if (trees != null) {
+                next.put(JavacTrees.class, trees);
+                trees.updateContext(next);
+            }
+
             context.clear();
             return next;
         }
@@ -1022,141 +1123,95 @@
     public JavaCompiler doProcessing(Context context,
                                      List<JCCompilationUnit> roots,
                                      List<ClassSymbol> classSymbols,
-                                     Iterable<? extends PackageSymbol> pckSymbols)
-        throws IOException {
+                                     Iterable<? extends PackageSymbol> pckSymbols) {
 
+        TaskListener taskListener = context.get(TaskListener.class);
         log = Log.instance(context);
 
-        Round round = new Round(context, 1);
-        round.compiler.todo.clear(); // free the compiler's resources
-
-        // The reverse() in the following line is to maintain behavioural
-        // compatibility with the previous revision of the code. Strictly speaking,
-        // it should not be necessary, but a javah golden file test fails without it.
-        round.topLevelClasses =
-                getTopLevelClasses(roots).prependList(classSymbols.reverse());
-
-        round.packageInfoFiles = getPackageInfoFiles(roots);
-
         Set<PackageSymbol> specifiedPackages = new LinkedHashSet<PackageSymbol>();
         for (PackageSymbol psym : pckSymbols)
             specifiedPackages.add(psym);
         this.specifiedPackages = Collections.unmodifiableSet(specifiedPackages);
 
-        ComputeAnnotationSet annotationComputer = new ComputeAnnotationSet(elementUtils);
-        round.findAnnotationsPresent(annotationComputer);
+        Round round = new Round(context, roots, classSymbols);
 
-        boolean errorStatus = false;
-
-        runAround:
-        while (true) {
-            if ((fatalErrors && round.errorCount() != 0)
-                    || (werror && round.warningCount() != 0)) {
-                errorStatus = true;
-                break runAround;
-            }
-
+        boolean errorStatus;
+        boolean moreToDo;
+        do {
+            // Run processors for round n
             round.run(false, false);
 
-            /*
-             * Processors for round n have run to completion.  Prepare
-             * for round (n+1) by checked for errors raised by
-             * annotation processors and then checking for syntax
-             * errors on any generated source files.
-             */
-            if (messager.errorRaised()) {
+            // Processors for round n have run to completion.
+            // Check for errors and whether there is more work to do.
+            errorStatus = round.unrecoverableError();
+            moreToDo = moreToDo();
+
+            round.showDiagnostics(errorStatus || showResolveErrors);
+
+            // Set up next round.
+            // Copy mutable collections returned from filer.
+            round = round.next(
+                    new LinkedHashSet<JavaFileObject>(filer.getGeneratedSourceFileObjects()),
+                    new LinkedHashMap<String,JavaFileObject>(filer.getGeneratedClasses()));
+
+             // Check for errors during setup.
+            if (round.unrecoverableError())
                 errorStatus = true;
-                break runAround;
-            }
 
-            if (!moreToDo())
-                break runAround; // No new files
-
-            round = round.next();
-
-            List<JCCompilationUnit> parsedFiles = round.parseNewSourceFiles();
-            roots = cleanTrees(roots).appendList(parsedFiles);
-
-            // Check for errors after parsing
-            if (round.unrecoverableError()) {
-                errorStatus = true;
-                break runAround;
-            }
-
-            List<ClassSymbol> newClasses = round.enterNewClassFiles();
-            round.enterTrees(roots);
-
-            round.topLevelClasses = join(
-                    getTopLevelClasses(parsedFiles),
-                    getTopLevelClassesFromClasses(newClasses));
-
-            round.packageInfoFiles = join(
-                    getPackageInfoFiles(parsedFiles),
-                    getPackageInfoFilesFromClasses(newClasses));
-
-            round.findAnnotationsPresent(annotationComputer);
-            round.updateProcessingState();
-        }
+        } while (moreToDo && !errorStatus);
 
         // run last round
         round.run(true, errorStatus);
-
-        // Add any sources generated during the last round to the set
-        // of files to be compiled.
-        if (moreToDo()) {
-            List<JCCompilationUnit> parsedFiles = round.parseNewSourceFiles();
-            roots = cleanTrees(roots).appendList(parsedFiles);
-        }
-
-        // Set error status for any files compiled and generated in
-        // the last round
-        if (round.unrecoverableError() || (werror && round.warningCount() != 0))
-            errorStatus = true;
-
-        round = round.next();
+        round.showDiagnostics(true);
 
         filer.warnIfUnclosedFiles();
         warnIfUnmatchedOptions();
 
-       /*
-        * If an annotation processor raises an error in a round,
-        * that round runs to completion and one last round occurs.
-        * The last round may also occur because no more source or
-        * class files have been generated.  Therefore, if an error
-        * was raised on either of the last *two* rounds, the compile
-        * should exit with a nonzero exit code.  The current value of
-        * errorStatus holds whether or not an error was raised on the
-        * second to last round; errorRaised() gives the error status
-        * of the last round.
-        */
-        errorStatus = errorStatus || messager.errorRaised();
+        /*
+         * If an annotation processor raises an error in a round,
+         * that round runs to completion and one last round occurs.
+         * The last round may also occur because no more source or
+         * class files have been generated.  Therefore, if an error
+         * was raised on either of the last *two* rounds, the compile
+         * should exit with a nonzero exit code.  The current value of
+         * errorStatus holds whether or not an error was raised on the
+         * second to last round; errorRaised() gives the error status
+         * of the last round.
+         */
+        if (messager.errorRaised()
+                || werror && round.warningCount() > 0 && round.errorCount() > 0)
+            errorStatus = true;
+
+        Set<JavaFileObject> newSourceFiles =
+                new LinkedHashSet<JavaFileObject>(filer.getGeneratedSourceFileObjects());
+        roots = cleanTrees(round.roots);
+
+        JavaCompiler compiler = round.finalCompiler(errorStatus);
+
+        if (newSourceFiles.size() > 0)
+            roots = roots.appendList(compiler.parseFiles(newSourceFiles));
+
+        errorStatus = errorStatus || (compiler.errorCount() > 0);
 
         // Free resources
         this.close();
 
-        TaskListener taskListener = this.context.get(TaskListener.class);
         if (taskListener != null)
             taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING));
 
-        JavaCompiler compiler;
-
         if (errorStatus) {
-            compiler = round.compiler;
-            compiler.log.nwarnings += messager.warningCount();
-            compiler.log.nerrors += messager.errorCount();
             if (compiler.errorCount() == 0)
                 compiler.log.nerrors++;
-        } else if (procOnly && !foundTypeProcessors) {
-            compiler = round.compiler;
+            return compiler;
+        }
+
+        if (procOnly && !foundTypeProcessors) {
             compiler.todo.clear();
-        } else { // Final compilation
-            round = round.next();
-            round.updateProcessingState();
-            compiler = round.compiler;
+        } else {
             if (procOnly && foundTypeProcessors)
                 compiler.shouldStopPolicy = CompileState.FLOW;
 
-            compiler.enterTrees(cleanTrees(roots));
+            compiler.enterTrees(roots);
         }
 
         return compiler;
@@ -1171,13 +1226,19 @@
     /**
      * Free resources related to annotation processing.
      */
-    public void close() throws IOException {
+    public void close() {
         filer.close();
         if (discoveredProcs != null) // Make calling close idempotent
             discoveredProcs.close();
         discoveredProcs = null;
-        if (processorClassLoader != null && processorClassLoader instanceof Closeable)
-            ((Closeable) processorClassLoader).close();
+        if (processorClassLoader != null && processorClassLoader instanceof Closeable) {
+            try {
+                ((Closeable) processorClassLoader).close();
+            } catch (IOException e) {
+                JCDiagnostic msg = diags.fragment("fatal.err.cant.close.loader");
+                throw new FatalError(msg, e);
+            }
+        }
     }
 
     private List<ClassSymbol> getTopLevelClasses(List<? extends JCCompilationUnit> units) {
@@ -1185,7 +1246,9 @@
         for (JCCompilationUnit unit : units) {
             for (JCTree node : unit.defs) {
                 if (node.getTag() == JCTree.CLASSDEF) {
-                    classes = classes.prepend(((JCClassDecl) node).sym);
+                    ClassSymbol sym = ((JCClassDecl) node).sym;
+                    assert sym != null;
+                    classes = classes.prepend(sym);
                 }
             }
         }
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Oct 19 16:26:29 2010 +0100
@@ -42,7 +42,9 @@
 compiler.err.already.defined.this.unit=\
     {0} is already defined in this compilation unit
 compiler.err.annotation.missing.default.value=\
-    annotation {0} is missing {1}
+    annotation {0} is missing value for the attribute {1}
+compiler.err.annotation.missing.default.value.1=\
+    annotation {0} is missing values for attributes {1}
 compiler.err.annotation.not.valid.for.type=\
     annotation not valid for a value of type {0}
 compiler.err.annotation.type.not.applicable=\
@@ -91,6 +93,8 @@
     required: {2}\n\
     found: {3}\n\
     reason: {6}
+compiler.err.cant.apply.symbols=\
+    no suitable {0} found for {1}({2})
 compiler.err.cant.apply.lambda=\
     lambda expression cannot be applied to given types\n\
     required: {0}\n\
@@ -170,6 +174,12 @@
 compiler.err.bad.defender.method.body=\
     body of defender method must be a method call
 
+compiler.warn.type.parameter.on.polymorphic.signature=\
+    change obsolete notation for MethodHandle invocations from x.<T>invoke(y) to (T)x.invoke(y)
+compiler.warn.wrong.target.for.polymorphic.signature.definition=\
+    MethodHandle API building requires -target 7 runtimes or better; current is -target {0}
+
+
 compiler.err.concrete.inheritance.conflict=\
     methods {0} from {1} and {2} from {3} are inherited with the same signature
 
@@ -609,6 +619,8 @@
     Fatal Error: Unable to find field {0}
 compiler.misc.fatal.err.cant.locate.ctor=\
     Fatal Error: Unable to find constructor for {0}
+compiler.misc.fatal.err.cant.close.loader=\
+    Fatal Error: Cannot close class loader for annotation processors
 
 #####
 
@@ -1136,11 +1148,11 @@
     no unique maximal instance exists for type variable {0} with upper bounds {1}
 compiler.misc.no.unique.minimal.instance.exists=\
     no unique minimal instance exists for type variable {0} with lower bounds {1}
-compiler.misc.no.conforming.instance.exists=\
+compiler.misc.infer.no.conforming.instance.exists=\
     no instance(s) of type variable(s) {0} exist so that {1} conforms to {2}
-compiler.misc.no.conforming.assignment.exists=\
+compiler.misc.infer.no.conforming.assignment.exists=\
     no instance(s) of type variable(s) {0} exist so that argument type {1} conforms to formal parameter type {2}
-compiler.misc.arg.length.mismatch=\
+compiler.misc.infer.arg.length.mismatch=\
     cannot instantiate from arguments because actual and formal argument lists differ in length
 compiler.misc.inferred.do.not.conform.to.bounds=\
     inferred type does not conform to declared bound(s)\n\
@@ -1156,6 +1168,16 @@
     type argument {0} inferred for {1} is not allowed in this context
 compiler.misc.diamond.invalid.args=\
     type arguments {0} inferred for {1} are not allowed in this context
+
+compiler.misc.explicit.param.do.not.conform.to.bounds=\
+    explicit type argument {0} does not conform to declared bound(s) {1}
+
+compiler.misc.arg.length.mismatch=\
+    actual and formal argument lists differ in length
+compiler.misc.no.conforming.assignment.exists=\
+    actual argument {0} cannot be converted to {1} by method invocation conversion
+compiler.misc.varargs.argument.mismatch=\
+    argument type {0} does not conform to vararg element type {1}
 #####
 
 ## The first argument ({0}) is a "kindname".
@@ -1302,6 +1324,10 @@
 compiler.misc.non.denotable.type=\
     Non-denotable type {0} not allowed here
 
+compiler.misc.inapplicable.method=\
+    {0} {1}.{2} is not applicable\n\
+    ({3})
+
 ########################################
 # Diagnostics for language feature changes
 ########################################
@@ -1317,6 +1343,10 @@
     underscores in literals are not supported in -source {0}\n\
 (use -source 7 or higher to enable underscores in literals)
 
+compiler.err.unsupported.exotic.id=\
+    exotic identifiers #"___" are not supported in -source {0}\n\
+(use -source 7 or higher to enable exotic identifiers)
+
 compiler.err.automatic.resource.management.not.supported.in.source=\
     automatic resource management is not supported in -source {0}\n\
 (use -source 7 or higher to enable automatic resource management)
--- a/src/share/classes/com/sun/tools/javac/resources/javac.properties	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties	Tue Oct 19 16:26:29 2010 +0100
@@ -74,7 +74,9 @@
 javac.opt.A=\
     Options to pass to annotation processors
 javac.opt.implicit=\
-    Specify whether or not to generate class files for implicitly referenced files 
+    Specify whether or not to generate class files for implicitly referenced files
+javac.opt.pkginfo=\
+    Specify handling of package-info files
 javac.opt.arg.class=\
     <class>
 javac.opt.arg.class.list=\
@@ -189,7 +191,7 @@
 
 javac.msg.usage.nonstandard.footer=\
 These options are non-standard and subject to change without notice.
-	
+
 javac.msg.bug=\
 An exception has occurred in the compiler ({0}). \
 Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport)  \
--- a/src/share/classes/com/sun/tools/javac/resources/legacy.properties	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/legacy.properties	Tue Oct 19 16:26:29 2010 +0100
@@ -565,6 +565,7 @@
 sun.tools.jar.resources = tiger legacy
 sun.util = tiger legacy
 sun.util.calendar = tiger legacy
+sun.util.locale = tiger legacy
 sun.util.logging.resources = tiger legacy
 sunw.io = tiger legacy
 sunw.util = tiger legacy
--- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue Oct 19 16:26:29 2010 +0100
@@ -353,6 +353,7 @@
     public abstract int getTag();
 
     /** Convert a tree to a pretty-printed string. */
+    @Override
     public String toString() {
         StringWriter s = new StringWriter();
         try {
@@ -388,6 +389,7 @@
 
     /** Return a shallow copy of this tree.
      */
+    @Override
     public Object clone() {
         try {
             return super.clone();
@@ -600,7 +602,17 @@
         @Override
         public void accept(Visitor v) { v.visitClassDef(this); }
 
-        public Kind getKind() { return Kind.CLASS; }
+        public Kind getKind() {
+            if ((mods.flags & Flags.ANNOTATION) != 0)
+                return Kind.ANNOTATION_TYPE;
+            else if ((mods.flags & Flags.INTERFACE) != 0)
+                return Kind.INTERFACE;
+            else if ((mods.flags & Flags.ENUM) != 0)
+                return Kind.ENUM;
+            else
+                return Kind.CLASS;
+        }
+
         public JCModifiers getModifiers() { return mods; }
         public Name getSimpleName() { return name; }
         public List<JCTypeParameter> getTypeParameters() {
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Tue Oct 19 16:26:29 2010 +0100
@@ -505,6 +505,10 @@
                 if (that.sym == sym) result = that;
                 else super.visitVarDef(that);
             }
+            public void visitTypeParameter(JCTypeParameter that) {
+                if (that.type.tsym == sym) result = that;
+                else super.visitTypeParameter(that);
+            }
         }
         DeclScanner s = new DeclScanner();
         tree.accept(s);
@@ -637,6 +641,18 @@
         }
     }
 
+    public static boolean isDeclaration(JCTree node) {
+        node = skipParens(node);
+        switch (node.getTag()) {
+        case JCTree.CLASSDEF:
+        case JCTree.METHODDEF:
+        case JCTree.VARDEF:
+            return true;
+        default:
+            return false;
+        }
+    }
+
     /** If this tree is an identifier or a field, return its symbol,
      *  otherwise return null.
      */
--- a/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Tue Oct 19 16:26:29 2010 +0100
@@ -65,8 +65,6 @@
  */
 public class BasicDiagnosticFormatter extends AbstractDiagnosticFormatter {
 
-    protected int currentIndentation = 0;
-
     /**
      * Create a basic formatter based on the supplied options.
      *
@@ -107,33 +105,28 @@
     }
 
     public String formatMessage(JCDiagnostic d, Locale l) {
-        int prevIndentation = currentIndentation;
-        try {
-            StringBuilder buf = new StringBuilder();
-            Collection<String> args = formatArguments(d, l);
-            String msg = localize(l, d.getCode(), args.toArray());
-            String[] lines = msg.split("\n");
-            if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) {
-                currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY);
-                buf.append(indent(lines[0], currentIndentation)); //summary
+        int currentIndentation = 0;
+        StringBuilder buf = new StringBuilder();
+        Collection<String> args = formatArguments(d, l);
+        String msg = localize(l, d.getCode(), args.toArray());
+        String[] lines = msg.split("\n");
+        if (getConfiguration().getVisible().contains(DiagnosticPart.SUMMARY)) {
+            currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUMMARY);
+            buf.append(indent(lines[0], currentIndentation)); //summary
+        }
+        if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) {
+            currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS);
+            for (int i = 1;i < lines.length; i++) {
+                buf.append("\n" + indent(lines[i], currentIndentation));
             }
-            if (lines.length > 1 && getConfiguration().getVisible().contains(DiagnosticPart.DETAILS)) {
-                currentIndentation += getConfiguration().getIndentation(DiagnosticPart.DETAILS);
-                for (int i = 1;i < lines.length; i++) {
-                    buf.append("\n" + indent(lines[i], currentIndentation));
-                }
+        }
+        if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
+            currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
+                for (String sub : formatSubdiagnostics(d, l)) {
+                    buf.append("\n" + indent(sub, currentIndentation));
             }
-            if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
-                currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
-                for (String sub : formatSubdiagnostics(d, l)) {
-                    buf.append("\n" + sub);
-                }
-            }
-            return buf.toString();
         }
-        finally {
-            currentIndentation = prevIndentation;
-        }
+        return buf.toString();
     }
 
     protected String addSourceLineIfNeeded(JCDiagnostic d, String msg) {
--- a/src/share/classes/com/sun/tools/javac/util/FatalError.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/FatalError.java	Tue Oct 19 16:26:29 2010 +0100
@@ -37,12 +37,6 @@
 public class FatalError extends Error {
     private static final long serialVersionUID = 0;
 
-    /** Construct a <code>FatalError</code> with no detail message.
-     */
-    public FatalError() {
-        super();
-    }
-
     /** Construct a <code>FatalError</code> with the specified detail message.
      *  @param d A diagnostic containing the reason for failure.
      */
@@ -50,6 +44,15 @@
         super(d.toString());
     }
 
+    /** Construct a <code>FatalError</code> with the specified detail message
+     * and cause.
+     *  @param d A diagnostic containing the reason for failure.
+     *  @param t An exception causing the error
+     */
+    public FatalError(JCDiagnostic d, Throwable t) {
+        super(d.toString(), t);
+    }
+
     /** Construct a <code>FatalError</code> with the specified detail message.
      *  @param s An English(!) string describing the failure, typically because
      *           the diagnostic resources are missing.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/util/Filter.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,39 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 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;
+
+/**
+ * Simple filter acting as a boolean predicate. Method accepts return true if
+ * the supplied element matches against the filter.
+ */
+public interface Filter<T> {
+    /**
+     * Does this element match against the filter?
+     * @param t element to be checked
+     * @return true if the element satisfy constraints imposed by filter
+     */
+    boolean accepts(T t);
+}
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Tue Oct 19 16:26:29 2010 +0100
@@ -25,8 +25,10 @@
 
 package com.sun.tools.javac.util;
 
+import java.util.EnumSet;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Set;
 
 import javax.tools.Diagnostic;
 import javax.tools.JavaFileObject;
@@ -83,7 +85,7 @@
          */
         public JCDiagnostic error(
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(ERROR, null, true, source, pos, key, args);
+            return create(ERROR, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
         }
 
         /**
@@ -96,7 +98,7 @@
          */
         public JCDiagnostic mandatoryWarning(
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, null, true, source, pos, key, args);
+            return create(WARNING, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
         }
 
         /**
@@ -111,7 +113,7 @@
         public JCDiagnostic mandatoryWarning(
                 LintCategory lc,
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, lc, true, source, pos, key, args);
+            return create(WARNING, lc, EnumSet.of(DiagnosticFlag.MANDATORY), source, pos, key, args);
         }
 
         /**
@@ -123,7 +125,7 @@
          */
         public JCDiagnostic warning(
                  LintCategory lc, String key, Object... args) {
-            return create(WARNING, lc, false, null, null, key, args);
+            return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
         }
 
         /**
@@ -135,7 +137,7 @@
          */
         public JCDiagnostic warning(
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, null, false, source, pos, key, args);
+            return create(WARNING, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
         }
 
         /**
@@ -149,7 +151,7 @@
          */
         public JCDiagnostic warning(
                  LintCategory lc, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(WARNING, lc, false, source, pos, key, args);
+            return create(WARNING, lc, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
         }
 
         /**
@@ -159,7 +161,7 @@
          *  @see MandatoryWarningHandler
          */
         public JCDiagnostic mandatoryNote(DiagnosticSource source, String key, Object... args) {
-            return create(NOTE, null, true, source, null, key, args);
+            return create(NOTE, null, EnumSet.of(DiagnosticFlag.MANDATORY), source, null, key, args);
         }
 
         /**
@@ -168,7 +170,7 @@
          *  @param args   Fields of the message.
          */
         public JCDiagnostic note(String key, Object... args) {
-            return create(NOTE, null, false, null, null, key, args);
+            return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
         }
 
         /**
@@ -180,7 +182,7 @@
          */
         public JCDiagnostic note(
                 DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(NOTE, null, false, source, pos, key, args);
+            return create(NOTE, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
         }
 
         /**
@@ -189,7 +191,7 @@
          *  @param args   Fields of the message.
          */
         public JCDiagnostic fragment(String key, Object... args) {
-            return create(FRAGMENT, null, false, null, null, key, args);
+            return create(FRAGMENT, null, EnumSet.noneOf(DiagnosticFlag.class), null, null, key, args);
         }
 
         /**
@@ -204,7 +206,7 @@
          */
         public JCDiagnostic create(
                 DiagnosticType kind, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return create(kind, null, false, source, pos, key, args);
+            return create(kind, null, EnumSet.noneOf(DiagnosticFlag.class), source, pos, key, args);
         }
 
         /**
@@ -218,8 +220,8 @@
          *  @param args        Fields of the message.
          */
         public JCDiagnostic create(
-                DiagnosticType kind, LintCategory lc, boolean isMandatory, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
-            return new JCDiagnostic(formatter, kind, lc, isMandatory, source, pos, qualify(kind, key), args);
+                DiagnosticType kind, LintCategory lc, Set<DiagnosticFlag> flags, DiagnosticSource source, DiagnosticPosition pos, String key, Object... args) {
+            return new JCDiagnostic(formatter, kind, lc, flags, source, pos, qualify(kind, key), args);
         }
 
         protected String qualify(DiagnosticType t, String key) {
@@ -240,7 +242,7 @@
         return new JCDiagnostic(getFragmentFormatter(),
                               FRAGMENT,
                               null,
-                              false,
+                              EnumSet.noneOf(DiagnosticFlag.class),
                               null,
                               null,
                               "compiler." + FRAGMENT.key + "." + key,
@@ -327,6 +329,11 @@
         private final int pos;
     }
 
+    public enum DiagnosticFlag {
+        MANDATORY,
+        RESOLVE_ERROR
+    }
+
     private final DiagnosticType type;
     private final DiagnosticSource source;
     private final DiagnosticPosition position;
@@ -334,7 +341,7 @@
     private final int column;
     private final String key;
     protected final Object[] args;
-    private final boolean mandatory;
+    private final Set<DiagnosticFlag> flags;
     private final LintCategory lintCategory;
 
     /**
@@ -350,7 +357,7 @@
     protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
                        DiagnosticType dt,
                        LintCategory lc,
-                       boolean mandatory,
+                       Set<DiagnosticFlag> flags,
                        DiagnosticSource source,
                        DiagnosticPosition pos,
                        String key,
@@ -361,7 +368,7 @@
         this.defaultFormatter = formatter;
         this.type = dt;
         this.lintCategory = lc;
-        this.mandatory = mandatory;
+        this.flags = flags;
         this.source = source;
         this.position = pos;
         this.key = key;
@@ -401,7 +408,7 @@
      * @return true if this diagnostic is required to be shown.
      */
     public boolean isMandatory() {
-        return mandatory;
+        return flags.contains(DiagnosticFlag.MANDATORY);
     }
 
     /**
@@ -520,8 +527,9 @@
         case NOTE:
             return Diagnostic.Kind.NOTE;
         case WARNING:
-            return mandatory ? Diagnostic.Kind.MANDATORY_WARNING
-                             : Diagnostic.Kind.WARNING;
+            return flags.contains(DiagnosticFlag.MANDATORY)
+                    ? Diagnostic.Kind.MANDATORY_WARNING
+                    : Diagnostic.Kind.WARNING;
         case ERROR:
             return Diagnostic.Kind.ERROR;
         default:
@@ -537,6 +545,14 @@
         return defaultFormatter.formatMessage(this, locale);
     }
 
+    public void setFlag(DiagnosticFlag flag) {
+        flags.add(flag);
+    }
+
+    public boolean isFlagSet(DiagnosticFlag flag) {
+        return flags.contains(flag);
+    }
+
     public static class MultilineDiagnostic extends JCDiagnostic {
 
         private final List<JCDiagnostic> subdiagnostics;
@@ -545,7 +561,7 @@
             super(other.defaultFormatter,
                   other.getType(),
                   other.getLintCategory(),
-                  other.isMandatory(),
+                  other.flags,
                   other.getDiagnosticSource(),
                   other.position,
                   other.getCode(),
--- a/src/share/classes/com/sun/tools/javac/util/Log.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Tue Oct 19 16:26:29 2010 +0100
@@ -28,17 +28,22 @@
 import java.io.*;
 import java.util.Arrays;
 import java.util.HashMap;
+import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Queue;
 import java.util.Set;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.api.DiagnosticFormatter;
+import com.sun.tools.javac.main.OptionName;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 
+import static com.sun.tools.javac.main.OptionName.*;
+
 /** A class for error logs. Reports errors and warnings, and
  *  keeps track of error numbers and positions.
  *
@@ -94,9 +99,6 @@
      */
     public boolean multipleErrors;
 
-    public Map<JCDiagnostic.Kind, List<JCDiagnostic>> suppressedDiagnostics =
-            new HashMap<JCDiagnostic.Kind, List<JCDiagnostic>>();
-
     /**
      * Diagnostic listener, if provided through programmatic
      * interface to javac (JSR 199).
@@ -118,6 +120,12 @@
      */
     private JavacMessages messages;
 
+    /**
+     * Deferred diagnostics
+     */
+    public boolean deferDiagnostics;
+    public Queue<JCDiagnostic> deferredDiagnostics = new ListBuffer<JCDiagnostic>();
+
     /** Construct a log with given I/O redirections.
      */
     @Deprecated
@@ -129,15 +137,14 @@
         this.noticeWriter = noticeWriter;
 
         Options options = Options.instance(context);
-        this.dumpOnError = options.get("-doe") != null;
-        this.promptOnError = options.get("-prompt") != null;
-        this.emitWarnings = options.get("-Xlint:none") == null;
-        this.suppressNotes = options.get("suppressNotes") != null;
-        this.MaxErrors = getIntOption(options, "-Xmaxerrs", getDefaultMaxErrors());
-        this.MaxWarnings = getIntOption(options, "-Xmaxwarns", getDefaultMaxWarnings());
-		this.enabled = true;
+        this.dumpOnError = options.isSet(DOE);
+        this.promptOnError = options.isSet(PROMPT);
+        this.emitWarnings = options.isUnset(XLINT_CUSTOM, "none");
+        this.suppressNotes = options.isSet("suppressNotes");
+        this.MaxErrors = getIntOption(options, XMAXERRS, getDefaultMaxErrors());
+        this.MaxWarnings = getIntOption(options, XMAXWARNS, getDefaultMaxWarnings());
 
-        boolean rawDiagnostics = options.get("rawDiagnostics") != null;
+        boolean rawDiagnostics = options.isSet("rawDiagnostics");
         messages = JavacMessages.instance(context);
         this.diagFormatter = rawDiagnostics ? new RawDiagnosticFormatter(options) :
                                               new BasicDiagnosticFormatter(options, messages);
@@ -151,7 +158,7 @@
             expectDiagKeys = new HashSet<String>(Arrays.asList(ek.split(", *")));
     }
     // where
-        private int getIntOption(Options options, String optionName, int defaultValue) {
+        private int getIntOption(Options options, OptionName optionName, int defaultValue) {
             String s = options.get(optionName);
             try {
                 if (s != null) {
@@ -213,12 +220,6 @@
      */
     public int nwarnings = 0;
 
-    /**
-     * Whether or not an unrecoverable error has been seen.
-     * Unrecoverable errors prevent subsequent annotation processing.
-     */
-    public boolean unrecoverableError;
-
     /** A set of all errors generated so far. This is used to avoid printing an
      *  error message more than once. For each error, a pair consisting of the
      *  source file name and source code position of the error is added to the set.
@@ -229,15 +230,14 @@
         return diagListener != null;
     }
 
-    public void setEnabled(boolean enabled) {
-        if (!enabled) {
-            suppressedDiagnostics.clear();
+    public List<JCDiagnostic> getDeferredDiags(JCDiagnostic.Kind kind) {
+        ListBuffer<JCDiagnostic> diags = ListBuffer.lb();
+        for (JCDiagnostic diag : deferredDiagnostics) {
+            if (diag.getKind() == kind) {
+               diags.append(diag);
+            }
         }
-        this.enabled = enabled;
-    }
-
-    public boolean isEnabled() {
-        return enabled;
+        return diags.toList();
     }
 
     public void setEndPosTable(JavaFileObject name, Map<JCTree, Integer> table) {
@@ -367,20 +367,32 @@
         nwarnings++;
     }
 
+    /** Report all deferred diagnostics, and clear the deferDiagnostics flag. */
+    public void reportDeferredDiagnostics() {
+        reportDeferredDiagnostics(EnumSet.allOf(JCDiagnostic.Kind.class));
+    }
+
+    /** Report selected deferred diagnostics, and clear the deferDiagnostics flag. */
+    public void reportDeferredDiagnostics(Set<JCDiagnostic.Kind> kinds) {
+        deferDiagnostics = false;
+        JCDiagnostic d;
+        while ((d = deferredDiagnostics.poll()) != null) {
+            if (kinds.contains(d.getKind()))
+                report(d);
+        }
+    }
+
     /**
      * Common diagnostic handling.
      * The diagnostic is counted, and depending on the options and how many diagnostics have been
      * reported so far, the diagnostic may be handed off to writeDiagnostic.
      */
     public void report(JCDiagnostic diagnostic) {
-        if (!enabled) {
-            List<JCDiagnostic> diags2 = suppressedDiagnostics.get(diagnostic.getKind());
-            if (diags2 == null) {
-                diags2 = List.nil();
-            }
-            suppressedDiagnostics.put(diagnostic.getKind(), diags2.prepend(diagnostic));
+        if (deferDiagnostics) {
+            deferredDiagnostics.add(diagnostic);
             return;
         }
+
         if (expectDiagKeys != null)
             expectDiagKeys.remove(diagnostic.getCode());
 
--- a/src/share/classes/com/sun/tools/javac/util/Names.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Names.java	Tue Oct 19 16:26:29 2010 +0100
@@ -105,7 +105,6 @@
     public final Name RuntimeInvisibleTypeAnnotations;
     public final Name RuntimeVisibleParameterAnnotations;
     public final Name RuntimeInvisibleParameterAnnotations;
-    public final Name PolymorphicSignature;
     public final Name Value;
     public final Name EnclosingMethod;
     public final Name desiredAssertionStatus;
@@ -121,7 +120,7 @@
     public final Name getClass;
     public final Name bindTo;
     public final Name type;
-    public final Name invoke;
+    public final Name invoke;	//allowTransitionalJSR292 only
     public final Name invokeVarargs;
     public final Name makeProxy;
     public final Name newProxyInstance;
@@ -235,7 +234,6 @@
         RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
         RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
         RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
-        PolymorphicSignature = fromString("PolymorphicSignature");
         Value = fromString("Value");
         EnclosingMethod = fromString("EnclosingMethod");
 
@@ -253,7 +251,7 @@
         getClass = fromString("getClass");
         bindTo = fromString("bindTo");
         type = fromString("type");
-        invoke = fromString("invoke");
+        invoke = fromString("invoke");   //allowTransitionalJSR292 only
         invokeVarargs = fromString("invokeVarargs");
         makeProxy = fromString("makeProxy");
         newProxyInstance = fromString("newProxyInstance");
@@ -306,7 +304,7 @@
     }
 
     protected Name.Table createTable(Options options) {
-        boolean useUnsharedTable = options.get("useUnsharedTable") != null;
+        boolean useUnsharedTable = options.isSet("useUnsharedTable");
         if (useUnsharedTable)
             return new UnsharedNameTable(this);
         else
--- a/src/share/classes/com/sun/tools/javac/util/Options.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Options.java	Tue Oct 19 16:26:29 2010 +0100
@@ -25,8 +25,9 @@
 
 package com.sun.tools.javac.util;
 
+import java.util.*;
 import com.sun.tools.javac.main.OptionName;
-import java.util.*;
+import static com.sun.tools.javac.main.OptionName.*;
 
 /** A table of all command-line options.
  *  If an option has an argument, the option name is mapped to the argument.
@@ -60,14 +61,62 @@
         context.put(optionsKey, this);
     }
 
+    /**
+     * Get the value for an undocumented option.
+     */
     public String get(String name) {
         return values.get(name);
     }
 
+    /**
+     * Get the value for an option.
+     */
     public String get(OptionName name) {
         return values.get(name.optionName);
     }
 
+    /**
+     * Check if the value for an undocumented option has been set.
+     */
+    public boolean isSet(String name) {
+        return (values.get(name) != null);
+    }
+
+    /**
+     * Check if the value for an option has been set.
+     */
+    public boolean isSet(OptionName name) {
+        return (values.get(name.optionName) != null);
+    }
+
+    /**
+     * Check if the value for a choice option has been set to a specific value.
+     */
+    public boolean isSet(OptionName name, String value) {
+        return (values.get(name.optionName + value) != null);
+    }
+
+    /**
+     * Check if the value for an undocumented option has not been set.
+     */
+    public boolean isUnset(String name) {
+        return (values.get(name) == null);
+    }
+
+    /**
+     * Check if the value for an option has not been set.
+     */
+    public boolean isUnset(OptionName name) {
+        return (values.get(name.optionName) == null);
+    }
+
+    /**
+     * Check if the value for a choice option has not been set to a specific value.
+     */
+    public boolean isUnset(OptionName name, String value) {
+        return (values.get(name.optionName + value) == null);
+    }
+
     public void put(String name, String value) {
         values.put(name, value);
     }
@@ -92,16 +141,14 @@
         return values.size();
     }
 
-    static final String LINT = "-Xlint";
-
     /** Check for a lint suboption. */
     public boolean lint(String s) {
         // return true if either the specific option is enabled, or
         // they are all enabled without the specific one being
         // disabled
         return
-            get(LINT + ":" + s)!=null ||
-            (get(LINT)!=null || get(LINT + ":all")!=null) &&
-                get(LINT+":-"+s)==null;
+            isSet(XLINT_CUSTOM, s) ||
+            (isSet(XLINT) || isSet(XLINT_CUSTOM, "all")) &&
+                isUnset(XLINT_CUSTOM, "-" + s);
     }
 }
--- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 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
@@ -107,9 +107,6 @@
             // force the use of Messager as a Log
             messager = Messager.instance0(context);
 
-            // force the use of the scanner that captures Javadoc comments
-            DocCommentScanner.Factory.preRegister(context);
-
             return new JavadocTool(context);
         } catch (CompletionFailure ex) {
             messager.error(Position.NOPOS, ex.getMessage());
--- a/src/share/classes/com/sun/tools/javah/JavahTask.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/JavahTask.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -526,15 +526,17 @@
     }
 
     private void showVersion(boolean full) {
-        log.println(version(full ? "full" : "release"));
+        log.println(version(full));
     }
 
     private static final String versionRBName = "com.sun.tools.javah.resources.version";
     private static ResourceBundle versionRB;
 
-    private String version(String key) {
-        // key=version:  mm.nn.oo[-milestone]
-        // key=full:     mm.mm.oo[-milestone]-build
+    private String version(boolean full) {
+        String msgKey = (full ? "javah.fullVersion" : "javah.version");
+        String versionKey = (full ? "full" : "release");
+        // versionKey=product:  mm.nn.oo[-milestone]
+        // versionKey=full:     mm.mm.oo[-milestone]-build
         if (versionRB == null) {
             try {
                 versionRB = ResourceBundle.getBundle(versionRBName);
@@ -543,7 +545,7 @@
             }
         }
         try {
-            return versionRB.getString(key);
+            return getMessage(msgKey, "javah", versionRB.getString(versionKey));
         }
         catch (MissingResourceException e) {
             return getMessage("version.unknown", System.getProperty("java.version"));
--- a/src/share/classes/com/sun/tools/javah/resources/l10n.properties	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/resources/l10n.properties	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,8 @@
 #
 # Version string.
 #
-javah.version=javah version "{0}"
+javah.version={0} version "{1}"
+javah.fullVersion={0} full version "{1}"
 
 #
 # These should have better diagnostics.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javah/resources/version.properties-template	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,28 @@
+#
+# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation.  Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+jdk=$(JDK_VERSION)
+full=$(FULL_VERSION)
+release=$(RELEASE)
--- a/src/share/classes/com/sun/tools/javap/CodeWriter.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java	Tue Oct 19 16:26:29 2010 +0100
@@ -239,7 +239,10 @@
                 new ArrayList<InstructionDetailWriter>();
         if (options.details.contains(InstructionDetailWriter.Kind.SOURCE)) {
             sourceWriter.reset(classWriter.getClassFile(), attr);
-            detailWriters.add(sourceWriter);
+            if (sourceWriter.hasSource())
+                detailWriters.add(sourceWriter);
+            else
+                println("(Source code not available)");
         }
 
         if (options.details.contains(InstructionDetailWriter.Kind.LOCAL_VARS)) {
--- a/src/share/classes/com/sun/tools/javap/SourceWriter.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/com/sun/tools/javap/SourceWriter.java	Tue Oct 19 16:26:29 2010 +0100
@@ -99,7 +99,10 @@
                 }
             }
         }
+    }
 
+    public boolean hasSource() {
+        return (sourceLines.length > 0);
     }
 
     private void setLineMap(Code_attribute attr) {
--- a/src/share/classes/javax/tools/ToolProvider.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/src/share/classes/javax/tools/ToolProvider.java	Tue Oct 19 16:26:29 2010 +0100
@@ -26,10 +26,14 @@
 package javax.tools;
 
 import java.io.File;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
 import java.net.URL;
 import java.net.URLClassLoader;
 import java.net.MalformedURLException;
+import java.util.HashMap;
 import java.util.Locale;
+import java.util.Map;
 import java.util.logging.Logger;
 import java.util.logging.Level;
 import static java.util.logging.Level.*;
@@ -44,8 +48,6 @@
  */
 public class ToolProvider {
 
-    private ToolProvider() {}
-
     private static final String propertyName = "sun.tools.ToolProvider";
     private static final String loggerName   = "javax.tools";
 
@@ -87,6 +89,9 @@
         return null;
     }
 
+    private static final String defaultJavaCompilerName
+        = "com.sun.tools.javac.api.JavacTool";
+
     /**
      * Gets the Java&trade; programming language compiler provided
      * with this platform.
@@ -94,13 +99,7 @@
      * {@code null} if no compiler is provided
      */
     public static JavaCompiler getSystemJavaCompiler() {
-        if (Lazy.compilerClass == null)
-            return trace(WARNING, "Lazy.compilerClass == null");
-        try {
-            return Lazy.compilerClass.newInstance();
-        } catch (Throwable e) {
-            return trace(WARNING, e);
-        }
+        return instance().getSystemTool(JavaCompiler.class, defaultJavaCompilerName);
     }
 
     /**
@@ -113,63 +112,109 @@
      * or {@code null} if no tools are provided
      */
     public static ClassLoader getSystemToolClassLoader() {
-        if (Lazy.compilerClass == null)
-            return trace(WARNING, "Lazy.compilerClass == null");
-        return Lazy.compilerClass.getClassLoader();
+        try {
+            Class<? extends JavaCompiler> c =
+                    instance().getSystemToolClass(JavaCompiler.class, defaultJavaCompilerName);
+            return c.getClassLoader();
+        } catch (Throwable e) {
+            return trace(WARNING, e);
+        }
     }
 
-    /**
-     * This class will not be initialized until one of the above
-     * methods are called.  This ensures that searching for the
-     * compiler does not affect platform start up.
-     */
-    static class Lazy  {
-        private static final String defaultJavaCompilerName
-            = "com.sun.tools.javac.api.JavacTool";
-        private static final String[] defaultToolsLocation
-            = { "lib", "tools.jar" };
-        static final Class<? extends JavaCompiler> compilerClass;
-        static {
-            Class<? extends JavaCompiler> c = null;
+
+    private static ToolProvider instance;
+
+    private static synchronized ToolProvider instance() {
+        if (instance == null)
+            instance = new ToolProvider();
+        return instance;
+    }
+
+    // Cache for tool classes.
+    // Use weak references to avoid keeping classes around unnecessarily
+    private Map<String, Reference<Class<?>>> toolClasses = new HashMap<String, Reference<Class<?>>>();
+
+    // Cache for tool classloader.
+    // Use a weak reference to avoid keeping it around unnecessarily
+    private Reference<ClassLoader> refToolClassLoader = null;
+
+
+    private ToolProvider() { }
+
+    private <T> T getSystemTool(Class<T> clazz, String name) {
+        Class<? extends T> c = getSystemToolClass(clazz, name);
+        try {
+            return c.asSubclass(clazz).newInstance();
+        } catch (Throwable e) {
+            trace(WARNING, e);
+            return null;
+        }
+    }
+
+    private <T> Class<? extends T> getSystemToolClass(Class<T> clazz, String name) {
+        Reference<Class<?>> refClass = toolClasses.get(name);
+        Class<?> c = (refClass == null ? null : refClass.get());
+        if (c == null) {
             try {
-                c = findClass().asSubclass(JavaCompiler.class);
-            } catch (Throwable t) {
-                trace(WARNING, t);
+                c = findSystemToolClass(name);
+            } catch (Throwable e) {
+                return trace(WARNING, e);
             }
-            compilerClass = c;
+            toolClasses.put(name, new WeakReference<Class<?>>(c));
+        }
+        return c.asSubclass(clazz);
+    }
+
+    private static final String[] defaultToolsLocation = { "lib", "tools.jar" };
+
+    private Class<?> findSystemToolClass(String toolClassName)
+        throws MalformedURLException, ClassNotFoundException
+    {
+        // try loading class directly, in case tool is on the bootclasspath
+        try {
+            return enableAsserts(Class.forName(toolClassName, false, null));
+        } catch (ClassNotFoundException e) {
+            trace(FINE, e);
+
+            // if tool not on bootclasspath, look in default tools location (tools.jar)
+            ClassLoader cl = (refToolClassLoader == null ? null : refToolClassLoader.get());
+            if (cl == null) {
+                File file = new File(System.getProperty("java.home"));
+                if (file.getName().equalsIgnoreCase("jre"))
+                    file = file.getParentFile();
+                for (String name : defaultToolsLocation)
+                    file = new File(file, name);
+
+                // if tools not found, no point in trying a URLClassLoader
+                // so rethrow the original exception.
+                if (!file.exists())
+                    throw e;
+
+                URL[] urls = { file.toURI().toURL() };
+                trace(FINE, urls[0].toString());
+
+                cl = URLClassLoader.newInstance(urls);
+                cl.setPackageAssertionStatus("com.sun.tools.javac", true);
+                refToolClassLoader = new WeakReference<ClassLoader>(cl);
+            }
+
+            return Class.forName(toolClassName, false, cl);
         }
 
-        private static Class<?> findClass()
-            throws MalformedURLException, ClassNotFoundException
-        {
-            try {
-                return enableAsserts(Class.forName(defaultJavaCompilerName, false, null));
-            } catch (ClassNotFoundException e) {
-                trace(FINE, e);
-            }
-            File file = new File(System.getProperty("java.home"));
-            if (file.getName().equalsIgnoreCase("jre"))
-                file = file.getParentFile();
-            for (String name : defaultToolsLocation)
-                file = new File(file, name);
-            URL[] urls = {file.toURI().toURL()};
-            trace(FINE, urls[0].toString());
-            ClassLoader cl = URLClassLoader.newInstance(urls);
-            cl.setPackageAssertionStatus("com.sun.tools.javac", true);
-            return Class.forName(defaultJavaCompilerName, false, cl);
+    }
+
+    private static Class<?> enableAsserts(Class<?> cls) {
+        try {
+            ClassLoader loader = cls.getClassLoader();
+            if (loader != null)
+                loader.setPackageAssertionStatus("com.sun.tools.javac", true);
+            else
+                trace(FINE, "loader == null");
+        } catch (SecurityException ex) {
+            trace(FINE, ex);
         }
+        return cls;
+    }
 
-        private static Class<?> enableAsserts(Class<?> cls) {
-            try {
-                ClassLoader loader = cls.getClassLoader();
-                if (loader != null)
-                    loader.setPackageAssertionStatus("com.sun.tools.javac", true);
-                else
-                    trace(FINE, "loader == null");
-            } catch (SecurityException ex) {
-                trace(FINE, ex);
-            }
-            return cls;
-        }
-    }
+
 }
--- a/test/tools/javac/6302184/T6302184.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/6302184/T6302184.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,4 +1,7 @@
 
+/**
+ * This is a test that uses ISO 8859 encoding.
+ */
 class T6302184 {
     
     T6302184() {
--- a/test/tools/javac/6304921/TestLog.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/6304921/TestLog.java	Tue Oct 19 16:26:29 2010 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -35,7 +35,6 @@
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.parser.Parser;
 import com.sun.tools.javac.parser.ParserFactory;
-import com.sun.tools.javac.parser.Scanner;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.Context;
@@ -60,7 +59,6 @@
         log.multipleErrors = true;
 
         JavacFileManager.preRegister(context);
-        Scanner.Factory sfac = Scanner.Factory.instance(context);
         ParserFactory pfac = ParserFactory.instance(context);
 
         final String text =
--- a/test/tools/javac/6758789/T6758789a.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/6758789/T6758789a.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,3 +1,3 @@
-T6758789a.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, null
-T6758789a.java:15:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, null
+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)
 2 errors
--- a/test/tools/javac/6840059/T6840059.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/6840059/T6840059.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,3 +1,3 @@
-T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, null
-T6840059.java:15:25: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, null
+T6840059.java:15:9: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, (compiler.misc.no.conforming.assignment.exists: java.lang.String, java.lang.Integer)
+T6840059.java:15:25: compiler.err.cant.apply.symbol.1: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, (compiler.misc.arg.length.mismatch)
 2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6857948/T6857948.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6857948
+ * @summary 6857948: Calling a constructor with a doubly bogus argument causes an internal error
+ * @author Maurizio Cimadamore
+ *
+ * @compile/fail/ref=T6857948.out -XDrawDiagnostics T6857948.java
+ */
+
+class Foo {
+   Foo(String v) {}
+};
+
+class Test {
+   public static void main() {
+      Foo f = new Foo("Hello!",nosuchfunction()) {};
+   }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6857948/T6857948.out	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,3 @@
+T6857948.java:16:32: compiler.err.cant.resolve.location.args: kindname.method, nosuchfunction, , , kindname.class, Test
+T6857948.java:16:50: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, (compiler.misc.arg.length.mismatch)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465a.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=T6863465a.out -XDrawDiagnostics T6863465a.java
+ */
+
+class T6863465a {
+    static class a { static interface b {} }
+    static class c extends a implements z.y {}
+    static class x { static interface y {} }
+    static class z extends x implements c.b {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465a.out	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+T6863465a.java:11:12: compiler.err.cyclic.inheritance: T6863465a.c
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465b.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=T6863465b.out -XDrawDiagnostics T6863465b.java
+ */
+
+class T6863465b {
+    static class a { static interface b { static interface d {} } }
+    static class c extends a implements z.y, z.d {}
+    static class x { static interface y {} }
+    static class z extends x implements c.b {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465b.out	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+T6863465b.java:11:12: compiler.err.cyclic.inheritance: T6863465b.c
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465c.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=T6863465c.out -XDrawDiagnostics T6863465c.java
+ */
+
+class T6863465c {
+    static class x { static interface y {} }
+    static class z extends x implements c.b {}
+    static class a { static interface b { static interface d {} } }
+    static class c extends a implements z.y, z.d {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465c.out	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,3 @@
+T6863465c.java:13:47: compiler.err.cant.resolve.location: kindname.class, d, , , kindname.class, T6863465c.z
+T6863465c.java:11:12: compiler.err.cyclic.inheritance: T6863465c.z
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465d.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,14 @@
+/**
+ * @test /nodynamiccopyright/
+ * @bug     6863465
+ * @summary javac doesn't detect circular subclass dependencies via qualified names
+ * @author  Maurizio Cimadamore
+ * @compile/fail/ref=T6863465d.out -XDrawDiagnostics T6863465d.java
+ */
+
+class T6863465d {
+    static class a { static interface b { static interface d {} } }
+    static class c extends a implements z.y, z.d {}
+    static class x { static interface y { static interface w {} } }
+    static class z extends x implements c.b, c.w {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465d.out	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,3 @@
+T6863465d.java:13:47: compiler.err.cant.resolve.location: kindname.class, w, , , kindname.class, T6863465d.c
+T6863465d.java:11:12: compiler.err.cyclic.inheritance: T6863465d.c
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/TestCircularClassfile.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6863465
+ * @summary  javac doesn't detect circular subclass dependencies via qualified names
+ * @run main TestCircularClassfile
+ */
+
+import java.io.*;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import java.util.EnumSet;
+
+public class TestCircularClassfile {
+
+    enum ClassName {
+        A("A"),
+        B("B"),
+        C("C"),
+        OBJECT("Object");
+
+        String name;
+
+        ClassName(String name) {
+            this.name = name;
+        }
+    }
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        final static String sourceStub = "class #C extends #S {}";
+
+        String source;
+
+        public JavaSource(ClassName clazz, ClassName sup) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = sourceStub.replace("#C", clazz.name).replace("#S", sup.name);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        int count = 0;
+        for (ClassName clazz : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) {
+            for (ClassName sup : EnumSet.of(ClassName.A, ClassName.B, ClassName.C)) {
+                if (sup.ordinal() < clazz.ordinal()) continue;
+                check("sub_"+count++, clazz, sup);
+            }
+        }
+    }
+
+    static JavaSource[] initialSources = new JavaSource[] {
+            new JavaSource(ClassName.A, ClassName.OBJECT),
+            new JavaSource(ClassName.B, ClassName.A),
+            new JavaSource(ClassName.C, ClassName.B)
+        };
+
+    static String workDir = System.getProperty("user.dir");
+
+    static void check(String destPath, ClassName clazz, ClassName sup) throws Exception {
+        File destDir = new File(workDir, destPath); destDir.mkdir();
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, null,
+                Arrays.asList("-d", destPath), null, Arrays.asList(initialSources));
+        ct.generate();
+        File fileToRemove = new File(destPath, clazz.name + ".class");
+        fileToRemove.delete();
+        JavaSource newSource = new JavaSource(clazz, sup);
+        DiagnosticChecker checker = new DiagnosticChecker();
+        ct = (JavacTask)tool.getTask(null, null, checker,
+                Arrays.asList("-cp", destPath), null, Arrays.asList(newSource));
+        ct.analyze();
+        if (!checker.errorFound) {
+            throw new AssertionError(newSource.source);
+        }
+    }
+
+    static class DiagnosticChecker implements DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR &&
+                    diagnostic.getCode().equals("compiler.err.cyclic.inheritance")) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD34.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6979683
+ * @summary Verify that casts can narrow and unbox at the same time
+ * @author jrose
+ *
+ * @compile/fail/ref=TestCast6979683_BAD34.java.errlog -XDrawDiagnostics TestCast6979683_BAD34.java
+ */
+
+public class TestCast6979683_BAD34 {
+    static boolean zconvBAD1(Number o) { return o; } //BAD
+    //...
+    //...
+    //...
+    //...
+    //...
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD34.java.errlog	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+TestCast6979683_BAD34.java:34:49: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Number, boolean
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD35.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6979683
+ * @summary Verify that casts can narrow and unbox at the same time
+ * @author jrose
+ *
+ * @compile/fail/ref=TestCast6979683_BAD35.java.errlog -XDrawDiagnostics TestCast6979683_BAD35.java
+ */
+
+public class TestCast6979683_BAD35 {
+    //...
+    static int iconvBAD1(Number o) { return o; } //BAD: cast needed
+    //...
+    //...
+    //...
+    //...
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD35.java.errlog	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+TestCast6979683_BAD35.java:35:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Number, int
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD36.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6979683
+ * @summary Verify that casts can narrow and unbox at the same time
+ * @author jrose
+ *
+ * @compile/fail/ref=TestCast6979683_BAD36.java.errlog -XDrawDiagnostics TestCast6979683_BAD36.java
+ */
+
+public class TestCast6979683_BAD36 {
+    //...
+    //...
+    static int iconvBAD2(Comparable<Integer> o) { return o; } //BAD: cast needed
+    //...
+    //...
+    //...
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD36.java.errlog	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+TestCast6979683_BAD36.java:36:58: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Comparable<java.lang.Integer>, int
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD37.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6979683
+ * @summary Verify that casts can narrow and unbox at the same time
+ * @author jrose
+ *
+ * @compile/fail/ref=TestCast6979683_BAD37.java.errlog -XDrawDiagnostics TestCast6979683_BAD37.java
+ */
+
+public class TestCast6979683_BAD37 {
+    //...
+    //...
+    //...
+    static int iconvBAD3(Comparable<Short> o) { return (int)o; } //BAD: wrong instance
+    //...
+    //...
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD37.java.errlog	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+TestCast6979683_BAD37.java:37:61: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Comparable<java.lang.Short>, int
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD38.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6979683
+ * @summary Verify that casts can narrow and unbox at the same time
+ * @author jrose
+ *
+ * @compile/fail/ref=TestCast6979683_BAD38.java.errlog -XDrawDiagnostics TestCast6979683_BAD38.java
+ */
+
+public class TestCast6979683_BAD38 {
+    //...
+    //...
+    //...
+    //...
+    static float cconvBAD1(Comparable<Character> o) { return o; } //BAD
+    //...
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD38.java.errlog	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+TestCast6979683_BAD38.java:38:62: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Comparable<java.lang.Character>, float
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD39.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6979683
+ * @summary Verify that casts can narrow and unbox at the same time
+ * @author jrose
+ *
+ * @compile/fail/ref=TestCast6979683_BAD39.java.errlog -XDrawDiagnostics TestCast6979683_BAD39.java
+ */
+
+public class TestCast6979683_BAD39 {
+    //...
+    //...
+    //...
+    //...
+    //...
+    static float cconvBAD2(Number o) { return (char)o; } //BAD
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_BAD39.java.errlog	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,2 @@
+TestCast6979683_BAD39.java:39:53: compiler.err.prob.found.req: (compiler.misc.inconvertible.types), java.lang.Number, char
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6979683/TestCast6979683_GOOD.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6979683
+ * @summary Verify that casts can narrow and unbox at the same time
+ * @author jrose
+ *
+ * @compile TestCast6979683_GOOD.java
+ * @run main TestCast6979683_GOOD
+ */
+
+public class TestCast6979683_GOOD {
+    public static void main(String... av) {
+        bugReportExample();
+        for (int x = -1; x <= 2; x++) {
+            zconvTests(x != 0);
+            iconvTests(x);
+            bconvTests((byte)x);
+            cconvTests((char)x);
+        }
+        System.out.println("Successfully ran "+tests+" tests.");
+    }
+
+    static int tests;
+    static void assertEquals(Object x, Object y) {
+        if (!x.equals(y)) {
+            throw new RuntimeException("assertEquals: "+x+" != "+y);
+        }
+        ++tests;
+    }
+
+    static void bugReportExample() {
+  {} // example in bug report:
+  Object x = (Object)1;
+  int y = (int)x;
+  {} // end example
+    }
+
+    static boolean zconv1(Boolean o) { return o; }
+    static boolean zconv2(Object o) { return (boolean)o; }
+    static boolean zconv3(Comparable<Boolean> o) { return (boolean)o; }
+
+    static void zconvTests(boolean x) {
+        assertEquals(x, zconv1(x));
+        assertEquals(x, zconv2(x));
+        assertEquals(x, zconv3(x));
+    }
+
+    static int iconv1(Integer o) { return o; }
+    static int iconv2(Object o) { return (int)o; }
+    static int iconv3(java.io.Serializable o) { return (int)o; }
+    static int iconv4(Number o) { return (int)o; }
+    static int iconv5(Comparable<Integer> o) { return (int)o; }
+
+    static void iconvTests(int x) {
+        assertEquals(x, iconv1(x));
+        assertEquals(x, iconv2(x));
+        assertEquals(x, iconv3(x));
+        assertEquals(x, iconv4(x));
+        assertEquals(x, iconv5(x));
+    }
+
+    static float bconv1(Byte o) { return o; }  // note type "float"
+    static float bconv2(Object o) { return (byte)o; }
+    static float bconv3(java.io.Serializable o) { return (byte)o; }
+    static float bconv4(Number o) { return (byte)o; }
+
+    static void bconvTests(byte x) {
+        float xf = x;
+        assertEquals(xf, bconv1(x));
+        assertEquals(xf, bconv2(x));
+        assertEquals(xf, bconv3(x));
+        assertEquals(xf, bconv4(x));
+    }
+
+    static float cconv1(Character o) { return o; }  // note type "float"
+    static float cconv2(Object o) { return (char)o; }
+    static float cconv3(java.io.Serializable o) { return (char)o; }
+    static float cconv4(Comparable<Character> o) { return (char)o; }
+
+    static void cconvTests(char x) {
+        float xf = x;
+        assertEquals(xf, cconv1(x));
+        assertEquals(xf, cconv2(x));
+        assertEquals(xf, cconv3(x));
+        assertEquals(xf, cconv4(x));
+    }
+
+}
--- a/test/tools/javac/CyclicInheritance.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/CyclicInheritance.out	Tue Oct 19 16:26:29 2010 +0100
@@ -4,6 +4,6 @@
 CyclicInheritance.java:22:1: compiler.err.cyclic.inheritance: I11
 CyclicInheritance.java:27:1: compiler.err.cyclic.inheritance: C211
 CyclicInheritance.java:31:1: compiler.err.cyclic.inheritance: C212
-CyclicInheritance.java:36:27: compiler.err.report.access: C221.I, private, C221
-CyclicInheritance.java:40:24: compiler.err.report.access: C222.C, private, C222
+CyclicInheritance.java:36:1: compiler.err.cyclic.inheritance: C221
+CyclicInheritance.java:40:1: compiler.err.cyclic.inheritance: C222
 8 errors
--- a/test/tools/javac/Diagnostics/6722234/T6722234a_1.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_1.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,2 +1,2 @@
-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>, null
+T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
 1 error
--- a/test/tools/javac/Diagnostics/6722234/T6722234a_2.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_2.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,3 +1,3 @@
-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>, null
+T6722234a.java:12:9: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T6722234a<compiler.misc.type.var: T, 1>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
 - 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	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,2 +1,2 @@
-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, null
+T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.type.captureof: 2, ? extends T6722234b>, List<T>)
 1 error
--- a/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,4 +1,4 @@
-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, null
+T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.captured.type: 2>, List<T>)
 - 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	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234c.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,2 +1,2 @@
-T6722234c.java:14:9: compiler.err.cant.apply.symbol: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, null
+T6722234c.java:14:9: compiler.err.cant.apply.symbol.1: kindname.method, m, T6722234c.String, java.lang.String, kindname.class, T6722234c, (compiler.misc.infer.no.conforming.assignment.exists: T, java.lang.String, T6722234c.String)
 1 error
--- a/test/tools/javac/Diagnostics/6799605/T6799605.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6799605/T6799605.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,4 +1,4 @@
-T6799605.java:17:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X>
-T6799605.java:18:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X>
-T6799605.java:19:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X>
+T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.inferred.do.not.conform.to.bounds: compiler.misc.type.captureof: 1, ?, T6799605<compiler.misc.type.captureof: 1, ?>))}
+T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type.captureof: 2, ?>, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))}
+T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type.captureof: 2, ?>, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))}
 3 errors
--- a/test/tools/javac/Diagnostics/6862608/T6862608a.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6862608/T6862608a.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,3 +1,3 @@
-T6862608a.java:19:41: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>, java.util.List<java.util.Comparator<?>>)
+T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, java.util.Comparator<T>, java.util.Comparator<java.lang.String>)), <T>java.util.Comparator<T>, java.util.Comparator<java.lang.String>
 - 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	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/Diagnostics/6862608/T6862608b.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,3 +1,3 @@
-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>, null
+T6862608b.java:11:7: compiler.err.cant.apply.symbol.1: kindname.method, test, compiler.misc.type.var: T, 1, compiler.misc.type.var: T, 2, kindname.class, T66862608b<compiler.misc.type.var: T, 1,compiler.misc.type.var: S, 2>, (compiler.misc.no.conforming.assignment.exists: compiler.misc.type.var: T, 2, compiler.misc.type.var: T, 1)
 - 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/InterfaceAssert.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/InterfaceAssert.java	Tue Oct 19 16:26:29 2010 +0100
@@ -23,9 +23,11 @@
 
 /*
  * @test
- * @bug 4399129
+ * @bug 4399129 6980724
  * @summary Check that assertions compile properly when nested in an interface
  * @author gafter
+ * @compile InterfaceAssert.java
+ * @run main InterfaceAssert
  */
 
 /*
--- a/test/tools/javac/NameCollision.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/NameCollision.out	Tue Oct 19 16:26:29 2010 +0100
@@ -1,2 +1,3 @@
 NameCollision.java:13:31: compiler.err.intf.expected.here
-1 error
+NameCollision.java:13:5: compiler.err.cyclic.inheritance: NameCollision.Runnable
+2 errors
--- a/test/tools/javac/T6326754.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/T6326754.out	Tue Oct 19 16:26:29 2010 +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.incompatible.types), T, T
-T6326754.java:70:11: compiler.err.cant.apply.symbol: kindname.method, setT, java.lang.Object, compiler.misc.no.args, kindname.class, TestC<T>, null
+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)
 - compiler.note.unchecked.filename: T6326754.java
 - compiler.note.unchecked.recompile
 4 errors
--- a/test/tools/javac/T6341023.java	Mon Oct 18 17:21:50 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6341023
- * @summary Tree API: Tree.Kind should have mapping to interface
- */
-
-import com.sun.source.tree.*;
-
-public class T6341023 {
-    public static void main(String... args) {
-        boolean ok = true;
-
-        for (Tree.Kind k: Tree.Kind.values()) {
-            //System.err.println(k + " " + k.asInterface());
-            Class<? extends Tree> i = k.asInterface();
-            switch (k) {
-            case POSTFIX_INCREMENT:
-            case POSTFIX_DECREMENT:
-            case PREFIX_INCREMENT:
-            case PREFIX_DECREMENT:
-            case UNARY_PLUS:
-            case UNARY_MINUS:
-            case BITWISE_COMPLEMENT:
-            case LOGICAL_COMPLEMENT:
-                ok = ok & verify(k, i, i == UnaryTree.class);
-                break;
-
-            case MULTIPLY:
-            case DIVIDE:
-            case REMAINDER:
-            case PLUS:
-            case MINUS:
-            case LEFT_SHIFT:
-            case RIGHT_SHIFT:
-            case UNSIGNED_RIGHT_SHIFT:
-            case LESS_THAN:
-            case GREATER_THAN:
-            case LESS_THAN_EQUAL:
-            case GREATER_THAN_EQUAL:
-            case EQUAL_TO:
-            case NOT_EQUAL_TO:
-            case AND:
-            case XOR:
-            case OR:
-            case CONDITIONAL_AND:
-            case CONDITIONAL_OR:
-                ok = ok & verify(k, i, i == BinaryTree.class);
-                break;
-
-            case MULTIPLY_ASSIGNMENT:
-            case DIVIDE_ASSIGNMENT:
-            case REMAINDER_ASSIGNMENT:
-            case PLUS_ASSIGNMENT:
-            case MINUS_ASSIGNMENT:
-            case LEFT_SHIFT_ASSIGNMENT:
-            case RIGHT_SHIFT_ASSIGNMENT:
-            case UNSIGNED_RIGHT_SHIFT_ASSIGNMENT:
-            case AND_ASSIGNMENT:
-            case XOR_ASSIGNMENT:
-            case OR_ASSIGNMENT:
-                ok = ok & verify(k, i, i == CompoundAssignmentTree.class);
-                break;
-
-            case INT_LITERAL:
-            case LONG_LITERAL:
-            case FLOAT_LITERAL:
-            case DOUBLE_LITERAL:
-            case BOOLEAN_LITERAL:
-            case CHAR_LITERAL:
-            case STRING_LITERAL:
-            case NULL_LITERAL:
-                ok = ok & verify(k, i, i == LiteralTree.class);
-                break;
-
-            case UNBOUNDED_WILDCARD:
-            case EXTENDS_WILDCARD:
-            case SUPER_WILDCARD:
-                ok = ok & verify(k, i, i == WildcardTree.class);
-                break;
-
-            case OTHER:
-                ok = ok & verify(k, i, i == null);
-                break;
-
-            default:
-                String ks = k.toString().replace("_", "") + "tree";
-                String iName = i.getName();
-                String is = iName.substring(iName.lastIndexOf(".") + 1);
-                ok = ok & verify(k, i, ks.equalsIgnoreCase(is));
-            }
-        }
-
-        if (!ok)
-            throw new AssertionError("test failed");
-    }
-
-    static boolean verify(Tree.Kind k, Class<?> c, boolean b) {
-        if (!b)
-            System.err.println("error: " + k + " " + c);
-        return b;
-    }
-}
--- a/test/tools/javac/T6358024.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/T6358024.java	Tue Oct 19 16:26:29 2010 +0100
@@ -60,7 +60,7 @@
              new Option[] { new XOption("-XprintRounds"),
                             new Option("-processorpath", "."),
                             new Option("-processor", self) },
-             11);
+             12);
     }
 
     static void test(JavacFileManager fm, JavaFileObject f, Option[] opts, int expect) throws Throwable {
--- a/test/tools/javac/T6403466.out	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/T6403466.out	Tue Oct 19 16:26:29 2010 +0100
@@ -13,6 +13,10 @@
 Finished TaskEvent[ENTER,T6403466Wrapper.java,null]
 Started TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
 Finished TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
+Started TaskEvent[ENTER,T6403466.java,null]
+Started TaskEvent[ENTER,T6403466Wrapper.java,null]
+Finished TaskEvent[ENTER,T6403466.java,null]
+Finished TaskEvent[ENTER,T6403466Wrapper.java,null]
 Started TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
 Finished TaskEvent[ANNOTATION_PROCESSING_ROUND,null,null]
 Finished TaskEvent[ANNOTATION_PROCESSING,null,null]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6458749.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6458749
+ * @summary  TypeParameterElement.getEnclosedElements() throws NPE within javac
+ * @build T6458749
+ * @compile -processor T6458749 -proc:only T6458749.java
+ */
+
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.SourceVersion;
+
+@SupportedAnnotationTypes("*")
+public class T6458749<T> extends AbstractProcessor {
+    public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
+        if (!renv.processingOver()) {
+            for(TypeElement e : ElementFilter.typesIn(renv.getRootElements())) {
+                System.out.printf("Element %s:%n", e.toString());
+                try {
+                    for (TypeParameterElement tp : e.getTypeParameters()) {
+                        System.out.printf("Type param %s", tp.toString());
+                        if (! tp.getEnclosedElements().isEmpty()) {
+                            throw new AssertionError("TypeParameterElement.getEnclosedElements() should return empty list");
+                        }
+                    }
+                } catch (NullPointerException npe) {
+                    throw new AssertionError("NPE from TypeParameterElement.getEnclosedElements()", npe);
+                }
+            }
+        }
+        return true;
+    }
+
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6458823/MyProcessor.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,55 @@
+ /*
+  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+  *
+  * This code is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU General Public License version 2 only, as
+  * published by the Free Software Foundation.
+  *
+  * This code is distributed in the hope that it will be useful, but WITHOUT
+  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+  * version 2 for more details (a copy is included in the LICENSE file that
+  * accompanied this code).
+  *
+  * You should have received a copy of the GNU General Public License version
+  * 2 along with this work; if not, write to the Free Software Foundation,
+  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+  *
+  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+  * or visit www.oracle.com if you need additional information or have any
+  * questions.
+  */
+
+import java.util.Set;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.ElementFilter;
+import javax.lang.model.SourceVersion;
+import static javax.tools.Diagnostic.Kind.*;
+
+@SupportedAnnotationTypes("*")
+public class MyProcessor extends AbstractProcessor {
+    private Messager messager;
+    public void init(ProcessingEnvironment processingEnv) {
+        this.messager = processingEnv.getMessager();
+    }
+
+    public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
+        if (!renv.processingOver()) {
+            for(TypeElement e : ElementFilter.typesIn(renv.getRootElements())) {
+                for (TypeParameterElement tp : e.getTypeParameters()) {
+                    if (tp.getSimpleName().toString().length() > 1) {
+                        messager.printMessage(WARNING,
+                            "Type param names should be of length 1", tp);
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6458823/T6458823.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6458823
+ * @summary Messager messages on TypeParamterElements to not include position information.
+ *
+ * @compile MyProcessor.java T6458823.java
+ * @run main T6458823
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.Writer;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class T6458823 {
+    public static void main(String[] args) throws Exception {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            throw new RuntimeException("can't get javax.tools.JavaCompiler!");
+        }
+        DiagnosticCollector<JavaFileObject> diagColl =
+            new DiagnosticCollector<JavaFileObject>();
+        StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
+        List<String> options = new ArrayList<String>();
+        options.add("-processor");
+        options.add("MyProcessor");
+        options.add("-proc:only");
+        List<File> files = new ArrayList<File>();
+        files.add(new File(T6458823.class.getResource("TestClass.java").toURI()));
+        final CompilationTask task = compiler.getTask(null, fm, diagColl,
+            options, null, fm.getJavaFileObjectsFromFiles(files));
+        task.call();
+        int diagCount = 0;
+        for (Diagnostic<? extends JavaFileObject> diag : diagColl.getDiagnostics()) {
+            if (diag.getKind() != Diagnostic.Kind.WARNING) {
+                throw new AssertionError("Only warnings expected");
+            }
+            System.out.println(diag);
+            if (diag.getPosition() == Diagnostic.NOPOS) {
+                throw new AssertionError("No position info in message");
+            }
+            if (diag.getSource() == null) {
+                throw new AssertionError("No source info in message");
+            }
+            diagCount++;
+        }
+        if (diagCount != 2) {
+            throw new AssertionError("unexpected number of warnings: " +
+                diagCount + ", expected: 2");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6458823/TestClass.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+class TestClass<XYZ, ABC> {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6587674.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6587674
+ * @summary NoClassdefFound when anonymously extending a class.
+ */
+
+import java.util.Vector;
+
+public class T6587674 {
+    private static final Vector<String> list =
+        true ? null : new Vector<String>() { };
+
+    public static void main(String[] args) {
+        System.out.println("T6587674 runs fine!");
+    }
+}
--- a/test/tools/javac/T6855236.java	Mon Oct 18 17:21:50 2010 +0100
+++ b/test/tools/javac/T6855236.java	Tue Oct 19 16:26:29 2010 +0100
@@ -71,12 +71,10 @@
 
         @Override
         public Object visitMethodInvocation(MethodInvocationTree node, Trees p) {
-            System.out.print("current path: ");
+            System.out.println("current path: ");
             for (Tree t : getCurrentPath()) {
-                System.out.print('/');
-                System.out.print(t);
-           }
-            System.out.println();
+                System.out.println("    " + t.getKind() + ": " + trim(t, 64));
+            }
             System.out.println("parent path: " + getCurrentPath().getParentPath());
             System.out.println("method select: " + node.getMethodSelect().toString());
             for (ExpressionTree arg : node.getArguments()) {
@@ -88,12 +86,20 @@
         @Override
         public Object visitExpressionStatement(ExpressionStatementTree node, Trees p) {
             ExpressionTree t = node.getExpression();
-            System.out.println("expression statement: " + t.toString());
+            System.out.println();
+            System.out.println("expression statement: " + trim(t, 64));
             return super.visitExpressionStatement(node, p);
         }
 
     }
 
+    private String trim(Tree t, int len) {
+        String s = t.toString().trim().replaceAll("\\s+", " ");
+        if (s.length() > len)
+            s = s.substring(0, len) + "...";
+        return s;
+    }
+
 }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6900149.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6900149
+ * @summary IllegalStateException when compiling same files and DiagnosticListener is set
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+
+public class T6900149 {
+    public static void main(String[] args) throws IOException {
+        DiagnosticCollector<JavaFileObject> diag =
+                new DiagnosticCollector<JavaFileObject>();
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm =
+                compiler.getStandardFileManager(null, null, null);
+        File emptyFile = File.createTempFile("Empty", ".java");
+        File[] files = new File[] { emptyFile, emptyFile };
+        CompilationTask task = compiler.getTask(null, fm, diag,
+                null, null, fm.getJavaFileObjects(files));
+        if (! task.call()) {
+            throw new AssertionError("compilation failed");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6956462/T6956462.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6956462
+ * @summary AssertionError exception throws in the Compiler Tree API in JDK 7.
+ *
+ * @build TestClass T6956462
+ * @run main T6956462
+ */
+
+import java.io.*;
+import java.net.URISyntaxException;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+
+public class T6956462 {
+    public static void main(String[] args) throws Exception {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        if (compiler == null) {
+            throw new RuntimeException("can't get javax.tools.JavaCompiler!");
+        }
+        StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null);
+        List<File> files = new ArrayList<File>();
+        files.add(new File(T6956462.class.getResource("TestClass.java").toURI()));
+        final CompilationTask task = compiler.getTask(null, fm, null,
+            null, null, fm.getJavaFileObjectsFromFiles(files));
+        JavacTask javacTask = (JavacTask) task;
+        for (CompilationUnitTree cu : javacTask.parse()) {
+            cu.accept(new MyVisitor(javacTask), null);
+        }
+    }
+
+    private static class MyVisitor extends SimpleTreeVisitor<Tree, Void> {
+        private final Trees trees;
+        private CompilationUnitTree file;
+
+        private MyVisitor(JavacTask javac) {
+            this.trees = Trees.instance(javac);
+        }
+
+        @Override
+        public Tree visitCompilationUnit(CompilationUnitTree file, Void v) {
+            this.file = file;
+            for (Tree typeDecl : file.getTypeDecls()) {
+                typeDecl.accept(this, v);
+            }
+            return null;
+        }
+
+        @Override
+        public Tree visitImport(ImportTree imp, Void v) {
+            return null;
+        }
+
+        @Override
+        public Tree visitMethodInvocation(MethodInvocationTree invoke, Void v) {
+            invoke.getMethodSelect().accept(this, v);
+            return null;
+        }
+
+        @Override
+        public Tree visitBlock(BlockTree block, Void v) {
+            for (StatementTree stat : block.getStatements()) {
+                stat.accept(this, v);
+            }
+            return null;
+        }
+
+        @Override
+        public Tree visitClass(ClassTree clazz, Void v) {
+            for (Tree member : clazz.getMembers()) {
+                member.accept(this, v);
+            }
+            return null;
+        }
+
+        @Override
+        public Tree visitIdentifier(IdentifierTree ident, Void v) {
+            trees.getScope(trees.getPath(file, ident));
+            return null;
+        }
+
+        @Override
+        public Tree visitMethod(MethodTree method, Void v) {
+            method.getBody().accept(this, v);
+            return null;
+        }
+
+        @Override
+        public Tree visitMemberSelect(MemberSelectTree select, Void v) {
+            select.getExpression().accept(this, v);
+            return null;
+        }
+
+        @Override
+        public Tree visitVariable(VariableTree var, Void v) {
+            var.getInitializer().accept(this, v);
+            return null;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6956462/TestClass.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.PrintStream;
+
+abstract class TestClass {
+    private void test() {
+        final PrintStream out = System.out;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6977800.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6977800
+ * @summary Regression: invalid resolution of supertype for local class
+ * @compile T6977800.java
+ */
+
+class T6977800 {
+    public static void test() {
+        class A {
+            int x = 1;
+        }
+        class B extends A {}
+        System.out.println(new B().x);
+    }
+
+    static class A {}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6985181.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6985181
+ * @summary Annotations lost from classfile
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T6985181 {
+    public static void main(String... args) throws Exception{
+        new T6985181().run();
+    }
+
+    public void run() throws Exception {
+        String code = "@interface Simple { }\ninterface Test<@Simple T> { }";
+
+        File srcFile = writeFile("Test.java", code);
+        File classesDir = new File("classes");
+        classesDir.mkdirs();
+        compile("-d", classesDir.getPath(), srcFile.getPath());
+        String out = javap(new File(classesDir, srcFile.getName().replace(".java", ".class")));
+        if (!out.contains("RuntimeInvisibleTypeAnnotations"))
+            throw new Exception("RuntimeInvisibleTypeAnnotations not found");
+    }
+
+    void compile(String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("Compilation failed: rc=" + rc);
+    }
+
+    String javap(File classFile) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String[] args = { "-v", classFile.getPath() };
+        int rc = com.sun.tools.javap.Main.run(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("javap failed: rc=" + rc);
+        return out;
+    }
+
+    File writeFile(String path, String body) throws IOException {
+        File f = new File(path);
+        FileWriter out = new FileWriter(f);
+        try {
+            out.write(body);
+        } finally {
+            out.close();
+        }
+        return f;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/TestPkgInfo.java	Tue Oct 19 16:26:29 2010 +0100
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6960424
+ * @summary new option -Xpkginfo for better control of when package-info.class is generated
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class TestPkgInfo {
+    enum OptKind {
+        NONE(null),
+        ALWAYS("-Xpkginfo:always"),
+        NONEMPTY("-Xpkginfo:nonempty"),
+        LEGACY("-Xpkginfo:legacy");
+        OptKind(String opt) { this.opt = opt; }
+        final String opt;
+    };
+
+    public static void main(String... args) throws Exception {
+        new TestPkgInfo().run(args);
+    }
+
+    public void run(String... args) throws Exception {
+        boolean[] booleanValues = { false, true };
+        for (OptKind ok: OptKind.values()) {
+            for (boolean sr: booleanValues) {
+                for (boolean cr: booleanValues) {
+                    for (boolean rr: booleanValues) {
+                        try {
+                            test(ok, sr, cr, rr);
+                        } catch (Exception e) {
+                            error("Exception: " + e);
+                        }<