changeset 743:fdf1b74d3437

Merge
author andrew
date Wed, 10 Nov 2010 19:07:04 +0000
parents 351c9df49ab7 (current diff) 2129a046f117 (diff)
children a75f9777ae63
files .hgtags make/build.xml src/share/classes/com/sun/tools/javac/jvm/ClassReader.java test/tools/javac/T6341023.java 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 285 files changed, 9291 insertions(+), 2410 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue Sep 14 11:37:19 2010 +0100
+++ b/.hgtags	Wed Nov 10 19:07:04 2010 +0000
@@ -85,3 +85,11 @@
 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
+01e8ac5fbefd35d2d9a0996213cf2390fd164e57 jdk7-b115
+857bfcea3f30cb5f4ae96f46a53ae1c772f9b0e5 jdk7-b116
--- a/make/build.xml	Tue Sep 14 11:37:19 2010 +0100
+++ b/make/build.xml	Wed Nov 10 19:07:04 2010 +0000
@@ -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>
@@ -621,7 +622,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>
 
@@ -673,6 +674,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"/>
@@ -812,7 +814,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}/"/>
@@ -826,7 +829,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}:${build.bootstrap.dir}/classes:${ant.home}/lib/ant.jar"/>
@@ -935,7 +939,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"/>
@@ -955,6 +960,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/netbeans/langtools/build.xml	Tue Sep 14 11:37:19 2010 +0100
+++ b/make/netbeans/langtools/build.xml	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/bin/launcher.sh-template	Wed Nov 10 19:07:04 2010 +0000
@@ -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":$cp 
+       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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/source/tree/Tree.java	Wed Nov 10 19:07:04 2010 +0000
@@ -94,7 +94,7 @@
         CATCH(CatchTree.class),
 
         /**
-         * Used for instances of {@link ClassTree}.
+         * Used for instances of {@link ClassTree} representing classes.
          */
         CLASS(ClassTree.class),
 
@@ -558,6 +558,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/source/util/TreeScanner.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/apt/main/JavaCompiler.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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/apt/mirror/declaration/AnnotationProxyMaker.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/apt/mirror/declaration/AnnotationProxyMaker.java	Wed Nov 10 19:07:04 2010 +0000
@@ -250,9 +250,13 @@
         /**
          * Sets "value" to an ExceptionProxy indicating a type mismatch.
          */
-        private void typeMismatch(final Method method, final Attribute attr) {
-            value = new ExceptionProxy() {
+        private void typeMismatch(Method method, final Attribute attr) {
+            class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
                 private static final long serialVersionUID = 8473323277815075163L;
+                transient final Method method;
+                AnnotationTypeMismatchExceptionProxy(Method method) {
+                    this.method = method;
+                }
                 public String toString() {
                     return "<error>";   // eg:  @Anno(value=<error>)
                 }
@@ -260,7 +264,8 @@
                     return new AnnotationTypeMismatchException(method,
                                 attr.type.toString());
                 }
-            };
+            }
+            value = new AnnotationTypeMismatchExceptionProxy(method);
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Attribute.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Wed Nov 10 19:07:04 2010 +0000
@@ -241,6 +241,12 @@
      */
     public static final long POLYMORPHIC_SIGNATURE = 1L<<40;
 
+    /**
+     * 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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Scope.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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);
@@ -171,11 +174,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 static SourceVersion toSourceVersion(Source source) {
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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;
             }
@@ -1214,7 +1229,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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;
 
@@ -336,6 +341,7 @@
         context.put(symtabKey, this);
 
         names = Names.instance(context);
+        scopeCounter = Scope.ScopeCounter.instance(context);
         target = Target.instance(context);
 
         // Create the unknown type
@@ -354,6 +360,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
@@ -368,7 +375,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);
@@ -381,7 +388,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.
@@ -471,7 +478,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;
@@ -483,7 +490,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/TypeAnnotations.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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 static com.sun.tools.javac.code.Type.*;
@@ -68,6 +69,7 @@
         new Context.Key<Types>();
 
     final Symtab syms;
+    final Scope.ScopeCounter scopeCounter;
     final JavacMessages messages;
     final Names names;
     final boolean allowBoxing;
@@ -88,6 +90,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);
@@ -914,7 +917,7 @@
             return true;
 
         if (t.isPrimitive() != s.isPrimitive())
-            return allowBoxing && isConvertible(t, s, warn);
+            return allowBoxing && (isConvertible(t, s, warn) || isConvertible(s, t, warn));
 
         if (warn != warnStack.head) {
             try {
@@ -1973,45 +1976,78 @@
             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));
+    // <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();
+            }
         }
-        MethodSymbol impl = cache.get(origin);
-        if (impl == null) {
+
+        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);
+                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) {
             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);
+                for (Scope.Entry e = c.members().lookup(ms.name, implFilter);
                      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) {
-                            impl = m;
-                            cache.put(origin, m);
-                            return impl;
-                        }
-                    }
+                    if (e.sym != null &&
+                             e.sym.overrides(ms, origin, types, checkResult))
+                        return (MethodSymbol)e.sym;
                 }
             }
+            return null;
         }
-        return impl;
     }
 
+    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
@@ -3554,4 +3590,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Annotate.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Nov 10 19:07:04 2010 +0000
@@ -119,10 +119,10 @@
         allowAnonOuterThis = source.allowAnonOuterThis();
         allowStringsInSwitch = source.allowStringsInSwitch();
         sourceName = source.name;
-        relax = (options.get("-retrofit") != null ||
-                 options.get("-relax") != null);
-        useBeforeDeclarationWarning = options.get("useBeforeDeclarationWarning") != null;
-        enableSunApiLintControl = options.get("enableSunApiLintControl") != null;
+        relax = (options.isSet("-retrofit") ||
+                 options.isSet("-relax"));
+        useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning");
+        enableSunApiLintControl = options.isSet("enableSunApiLintControl");
     }
 
     /** Switch: relax some constraints for retrofit mode.
@@ -328,6 +328,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);
@@ -342,6 +348,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);
@@ -578,6 +590,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) {
@@ -595,7 +609,7 @@
         } else if (checkExtensible &&
                    classExpected &&
                    (t.tsym.flags() & INTERFACE) != 0) {
-            log.error(tree.pos(), "no.intf.expected.here");
+                log.error(tree.pos(), "no.intf.expected.here");
             return types.createErrorType(t);
         }
         if (checkExtensible &&
@@ -1171,7 +1185,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;
     }
 
@@ -1405,7 +1422,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
@@ -1429,23 +1447,19 @@
                               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) {
+            if (!(rs.allowTransitionalJSR292 && typeargtypesNonRefOK)) {
                 chk.checkRefTypes(tree.typeargs, typeargtypes);
             }
 
@@ -2009,7 +2023,10 @@
     public void visitTypeCast(JCTypeCast tree) {
         Type clazztype = attribType(tree.clazz, env);
         chk.validate(tree.clazz, env, false);
-        Type exprtype = attribExpr(tree.expr, env, Infer.anyPoly);
+        //a fresh environment is required for 292 inference to work properly ---
+        //see Infer.instantiatePolymorphicSignatureInstance()
+        Env<AttrContext> localEnv = env.dup(tree);
+        Type exprtype = attribExpr(tree.expr, localEnv, Infer.anyPoly);
         Type owntype = chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
         if (exprtype.constValue() != null)
             owntype = cfolder.coerce(exprtype, owntype);
@@ -2845,7 +2862,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;
                 }
@@ -3186,4 +3202,104 @@
             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);
+        }
+    }
+    // </editor-fold>
 }
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Nov 10 19:07:04 2010 +0000
@@ -25,7 +25,6 @@
 
 package com.sun.tools.javac.comp;
 
-import com.sun.source.tree.AssignmentTree;
 import java.util.*;
 import java.util.Set;
 
@@ -46,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.
@@ -60,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;
@@ -86,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 +100,10 @@
         allowGenerics = source.allowGenerics();
         allowAnnotations = source.allowAnnotations();
         allowCovariantReturns = source.allowCovariantReturns();
-        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();
@@ -1727,6 +1730,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.
      *
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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);
 
         ClassType ct = (ClassType)c.type;
         if (owner.kind != PCK && (c.flags_field & STATIC) == 0) {
--- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Nov 10 19:07:04 2010 +0000
@@ -408,7 +408,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);
+            }
         }
     }
 
@@ -481,12 +483,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.
@@ -568,9 +571,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 -------------*/
@@ -1007,7 +1012,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,
@@ -1050,20 +1055,22 @@
             List<Type> rethrownTypes = chk.diff(thrownInTry, caughtInTry);
             for (JCExpression ct : subClauses) {
                 Type exc = 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);
+                if (exc != syms.unknownType) {
+                    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);
                 }
-                caughtInTry = chk.incl(exc, caughtInTry);
             }
             inits = initsTry.dup();
             uninits = uninitsTry.dup();
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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.*;
@@ -78,25 +80,12 @@
 
     }
 
-    public static class InferenceException extends RuntimeException {
+    public static class InferenceException extends Resolve.InapplicableMethodException {
         private static final long serialVersionUID = 0;
 
-        JCDiagnostic diagnostic;
-        JCDiagnostic.Factory diags;
-
         InferenceException(JCDiagnostic.Factory diags) {
-            this.diagnostic = null;
-            this.diags = diags;
+            super(diags);
         }
-
-        InferenceException setMessage(String key, Object... args) {
-            this.diagnostic = diags.fragment(key, args);
-            return this;
-        }
-
-        public JCDiagnostic getDiagnostic() {
-             return diagnostic;
-         }
     }
 
     public static class NoInstanceException extends InferenceException {
@@ -318,7 +307,7 @@
         Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
         if (!types.isSubtype(qtype1, to)) {
             throw unambiguousNoInstanceException
-                .setMessage("no.conforming.instance.exists",
+                .setMessage("infer.no.conforming.instance.exists",
                             that.tvars, that.qtype, to);
         }
         for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail)
@@ -376,6 +365,11 @@
         // instantiate all polymorphic argument types and
         // set up lower bounds constraints for undetvars
         Type varargsFormal = useVarargs ? formals.last() : null;
+        if (varargsFormal == null &&
+                actuals.size() != formals.size()) {
+            throw unambiguousNoInstanceException
+                .setMessage("infer.arg.length.mismatch");
+        }
         while (actuals.nonEmpty() && formals.head != varargsFormal) {
             Type formal = formals.head;
             Type actual = actuals.head.baseType();
@@ -388,19 +382,16 @@
                 : types.isSubtypeUnchecked(actual, undetFormal, warn);
             if (!works) {
                 throw unambiguousNoInstanceException
-                    .setMessage("no.conforming.assignment.exists",
+                    .setMessage("infer.no.conforming.assignment.exists",
                                 tvars, actualNoCapture, formal);
             }
             formals = formals.tail;
             actuals = actuals.tail;
             actualsNoCapture = actualsNoCapture.tail;
         }
-        if (formals.head != varargsFormal || // not enough args
-            !useVarargs && actuals.nonEmpty()) { // too many args
-            // argument lists differ in length
-            throw unambiguousNoInstanceException
-                .setMessage("arg.length.mismatch");
-        }
+
+        if (formals.head != varargsFormal) // not enough args
+            throw unambiguousNoInstanceException.setMessage("infer.arg.length.mismatch");
 
         // for varargs arguments as well
         if (useVarargs) {
@@ -414,7 +405,7 @@
                 boolean works = types.isConvertible(actual, elemUndet, warn);
                 if (!works) {
                     throw unambiguousNoInstanceException
-                        .setMessage("no.conforming.assignment.exists",
+                        .setMessage("infer.no.conforming.assignment.exists",
                                     tvars, actualNoCapture, elemType);
                 }
                 actuals = actuals.tail;
@@ -543,4 +534,68 @@
                                 args.head, bounds);
         }
     }
+
+    /**
+     * 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'. A correctness check ensures that
+            //env.next refers to the lexically enclosing environment in which
+            //the polymorphic signature call environment is nested.
+
+            switch (env.next.tree.getTag()) {
+                case JCTree.TYPECAST:
+                    JCTypeCast castTree = (JCTypeCast)env.next.tree;
+                    restype = (castTree.expr == env.tree) ?
+                        castTree.clazz.type :
+                        syms.objectType;
+                    break;
+                case JCTree.EXEC:
+                    JCTree.JCExpressionStatement execTree =
+                            (JCTree.JCExpressionStatement)env.next.tree;
+                    restype = (execTree.expr == env.tree) ?
+                        syms.voidType :
+                        syms.objectType;
+                    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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Nov 10 19:07:04 2010 +0000
@@ -29,6 +29,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;
@@ -67,6 +68,7 @@
     private Names names;
     private Log log;
     private Symtab syms;
+    private Scope.ScopeCounter scopeCounter;
     private Resolve rs;
     private Check chk;
     private Attr attr;
@@ -82,12 +84,14 @@
     private final Name classDollar;
     private Types types;
     private boolean debugLower;
+    private PkgInfo pkginfoOpt;
 
     protected Lower(Context context) {
         context.put(lowerKey, this);
         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);
@@ -105,7 +109,8 @@
 
         types = Types.instance(context);
         Options options = Options.instance(context);
-        debugLower = options.get("debuglower") != null;
+        debugLower = options.isSet("debuglower");
+        pkginfoOpt = PkgInfo.get(options);
     }
 
     /** The currently enclosing class.
@@ -566,7 +571,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;
@@ -2161,7 +2166,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())
@@ -2183,6 +2188,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;
@@ -2657,7 +2679,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;
@@ -2869,8 +2892,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -666,9 +668,9 @@
     public void visitTree(JCTree tree) {
     }
 
-
     public void visitErroneous(JCErroneous tree) {
-        memberEnter(tree.errs, env);
+        if (tree.errs != null)
+            memberEnter(tree.errs, env);
     }
 
     public Env<AttrContext> getMethodEnv(JCMethodDecl tree, Env<AttrContext> env) {
@@ -769,9 +771,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))
@@ -917,7 +927,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);
 
@@ -1079,7 +1089,7 @@
 
 
     private Env<AttrContext> baseEnv(JCClassDecl tree, Env<AttrContext> env) {
-        Scope baseScope = 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()) {
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Nov 10 19:07:04 2010 +0000
@@ -69,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)
@@ -106,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
@@ -246,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())
@@ -254,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)));
         }
     }
@@ -303,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;
@@ -326,7 +346,7 @@
                                                 pmt.tvars, typeargtypes);
                 for (; bounds.nonEmpty(); bounds = bounds.tail)
                     if (!types.isSubtypeUnchecked(actuals.head, bounds.head, warn))
-                        return null;
+                        throw inapplicableMethodException.setMessage("explicit.param.do.not.conform.to.bounds",actuals.head, bounds);
                 formals = formals.tail;
                 actuals = actuals.tail;
             }
@@ -339,7 +359,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) {
@@ -347,8 +368,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,
@@ -356,11 +378,18 @@
                                     allowBoxing,
                                     useVarargs,
                                     warn);
-        return
-            argumentsAcceptable(argtypes, mt.getParameterTypes(),
-                                allowBoxing, useVarargs, warn)
-            ? mt
-            : null;
+
+        checkRawArgumentsAcceptable(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
@@ -376,7 +405,7 @@
         try {
             return rawInstantiate(env, site, m, argtypes, typeargtypes,
                                   allowBoxing, useVarargs, warn);
-        } catch (Infer.InferenceException ex) {
+        } catch (InapplicableMethodException ex) {
             return null;
         }
     }
@@ -388,26 +417,76 @@
                                 boolean allowBoxing,
                                 boolean useVarargs,
                                 Warner warn) {
+        try {
+            checkRawArgumentsAcceptable(argtypes, formals, allowBoxing, useVarargs, warn);
+            return true;
+        } catch (InapplicableMethodException ex) {
+            return false;
+        }
+    }
+    void checkRawArgumentsAcceptable(List<Type> argtypes,
+                                List<Type> formals,
+                                boolean allowBoxing,
+                                boolean useVarargs,
+                                Warner warn) {
         Type varargsFormal = useVarargs ? formals.last() : null;
+        if (varargsFormal == null &&
+                argtypes.size() != formals.size()) {
+            throw inapplicableMethodException.setMessage("arg.length.mismatch"); // not enough args
+        }
+
         while (argtypes.nonEmpty() && formals.head != varargsFormal) {
             boolean works = allowBoxing
                 ? types.isConvertible(argtypes.head, formals.head, warn)
                 : types.isSubtypeUnchecked(argtypes.head, formals.head, warn);
-            if (!works) return false;
+            if (!works)
+                throw inapplicableMethodException.setMessage("no.conforming.assignment.exists",
+                        argtypes.head,
+                        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()) {
-            if (!types.isConvertible(argtypes.head, 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()) {
+                if (!types.isConvertible(argtypes.head, elt, warn))
+                    throw inapplicableMethodException.setMessage("varargs.argument.mismatch",
+                            argtypes.head,
+                            elt);
+                argtypes = argtypes.tail;
+            }
         }
-        return true;
+        return;
     }
+    // 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
@@ -568,6 +647,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,
@@ -580,30 +660,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;
             }
@@ -612,7 +679,7 @@
             return (bestSoFar.kind == ABSENT_MTH)
                 ? new AccessError(env, site, sym)
                 : bestSoFar;
-        }
+            }
         return (bestSoFar.kind > AMBIGUOUS)
             ? sym
             : mostSpecific(sym, bestSoFar, env, site,
@@ -759,13 +826,6 @@
                       boolean useVarargs,
                       boolean operator) {
         Symbol bestSoFar = methodNotFound;
-        if ((site.tsym.flags() & POLYMORPHIC_SIGNATURE) != 0 &&
-            allowPolymorphicSignature &&
-            site.tag == CLASS &&
-            !(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,
@@ -907,90 +967,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;
-        if (typeargtypes.isEmpty()) {
-            restype = syms.objectType;
-        } else {
-            restype = typeargtypes.head;
-            if (!typeargtypes.tail.isEmpty())
-                return methodNotFound;
-        }
-        List<Type> paramtypes = Type.map(argtypes, implicitArgType);
-        long flags;
-        List<Type> exType;
-        if (spMethod != null) {
-            exType = spMethod.getThrownTypes();
-            flags = spMethod.flags() & AccessFlags;
-        } else {
-            // make it throw all exceptions
-            //assert(site == syms.invokeDynamicType);
-            exType = List.of(syms.throwableType);
-            flags = PUBLIC | STATIC;
-        }
-        MethodType mtype = new MethodType(paramtypes,
-                                          restype,
-                                          exType,
-                                          syms.methodClass);
-        flags |= ABSTRACT | HYPOTHETICAL | POLYMORPHIC_SIGNATURE;
-        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);
-        }
-        assert argumentsAcceptable(argtypes, types.memberType(site, m).getParameterTypes(),
-                                   false, false, Warner.noWarnings);
-        assert null != instantiate(env, site, m, argtypes, typeargtypes, false, false, Warner.noWarnings);
-        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.
@@ -1325,11 +1301,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);
@@ -1346,6 +1323,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.
@@ -1358,27 +1341,89 @@
     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;
     }
 
+    /** 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
      *  found.
      *  @param pos       The position to use for error reporting.
@@ -1415,11 +1460,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());
@@ -1450,26 +1496,22 @@
                               Type site,
                               List<Type> argtypes,
                               List<Type> typeargtypes) {
-        Symbol sym = methodNotFound;
-        JCDiagnostic explanation = null;
+        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) {
-            final JCDiagnostic details = explanation;
+            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) {
@@ -1871,7 +1913,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;
         }
 
@@ -1879,7 +1922,6 @@
          */
         InapplicableSymbolError setWrongSym(Symbol sym) {
             this.sym = sym;
-            this.explanation = null;
             return this;
         }
 
@@ -1916,6 +1958,10 @@
             }
         }
 
+        void clear() {
+            explanation = null;
+        }
+
         @Override
         public Symbol access(Name name, TypeSymbol location) {
             return types.createErrorType(name, location, syms.errSymbol.type).tsym;
@@ -1928,6 +1974,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");
         }
@@ -1939,8 +1988,85 @@
                 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.flags() & VARARGS) != 0 && step == VARARITY) ||
+                          (sym.flags() & VARARGS) == 0 && step == (boxingEnabled ? BOX : BASIC));
+            }
         }
     }
 
@@ -2104,6 +2230,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java	Wed Nov 10 19:07:04 2010 +0000
@@ -283,12 +283,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))) {
@@ -304,7 +305,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)) {
@@ -327,6 +328,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
@@ -754,6 +760,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))
+            .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
  *************************************************************************/
@@ -786,6 +876,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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();
     }
@@ -1098,12 +1104,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
@@ -1289,6 +1289,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()));
         }
@@ -1987,7 +1990,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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 =
@@ -651,13 +655,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;
     }
 
@@ -692,7 +689,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;
@@ -708,7 +705,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)
@@ -723,7 +720,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)
@@ -747,7 +744,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;
@@ -785,7 +782,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;
@@ -815,29 +812,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Wed Nov 10 19:07:04 2010 +0000
@@ -46,6 +46,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.
  *
@@ -113,19 +114,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
--- a/src/share/classes/com/sun/tools/javac/jvm/Target.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Target.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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);
@@ -259,6 +261,14 @@
         return compareTo(JDK1_7) >= 0;
     }
 
+    /** 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 hasMethodHandles() {
+        return hasInvokedynamic();
+    }
+
     /** Although we may not have support for class literals, should we
      *  avoid initializing the class that the literal refers to?
      *  See 4468823
--- a/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -358,22 +355,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;
@@ -383,15 +380,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));
     }
 
@@ -514,7 +511,7 @@
 
     protected boolean shouldStop(CompileState cs) {
         if (shouldStopPolicy == null)
-            return (errorCount() > 0);
+            return (errorCount() > 0 || unrecoverableError());
         else
             return cs.ordinal() > shouldStopPolicy.ordinal();
     }
@@ -579,10 +576,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)));
             }
@@ -608,7 +603,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());
     }
@@ -778,7 +773,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;
@@ -868,14 +862,19 @@
     /**
      * Parses a list of files.
      */
-   public List<JCCompilationUnit> parseFiles(Iterable<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();
     }
 
@@ -916,6 +915,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;
     }
 
@@ -941,27 +949,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();
             }
@@ -969,8 +974,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());
     }
 
@@ -979,16 +983,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 log.unrecoverableError is set, the errors were parse errors
+            // 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 (log.unrecoverableError)
+            if (unrecoverableError()) {
+                log.reportDeferredDiagnostics();
                 return this;
+            }
         }
 
         // ASSERT: processAnnotations and procEnvImpl should have been set up by
@@ -1001,7 +1012,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();
             }
@@ -1010,6 +1021,7 @@
                 log.error("proc.no.explicit.annotation.processing.requested",
                           classnames);
             }
+            log.reportDeferredDiagnostics();
             return this; // continue regular compilation
         }
 
@@ -1022,6 +1034,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;
@@ -1036,7 +1049,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
@@ -1052,33 +1064,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);
     }
 
     /**
@@ -1119,6 +1144,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 {
@@ -1552,6 +1582,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/OptionName.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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/AnnotationProxyMaker.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java	Wed Nov 10 19:07:04 2010 +0000
@@ -250,9 +250,13 @@
         /**
          * Sets "value" to an ExceptionProxy indicating a type mismatch.
          */
-        private void typeMismatch(final Method method, final Attribute attr) {
-            value = new ExceptionProxy() {
+        private void typeMismatch(Method method, final Attribute attr) {
+            class AnnotationTypeMismatchExceptionProxy extends ExceptionProxy {
                 static final long serialVersionUID = 269;
+                transient final Method method;
+                AnnotationTypeMismatchExceptionProxy(Method method) {
+                    this.method = method;
+                }
                 public String toString() {
                     return "<error>";   // eg:  @Anno(value=<error>)
                 }
@@ -260,7 +264,8 @@
                     return new AnnotationTypeMismatchException(method,
                                 attr.type.toString());
                 }
-            };
+            }
+            value = new AnnotationTypeMismatchExceptionProxy(method);
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Wed Nov 10 19:07:04 2010 +0000
@@ -66,32 +66,26 @@
     private Types types;
     private Enter enter;
 
-    private static final Context.Key<JavacElements> KEY =
-            new Context.Key<JavacElements>();
-
     public static JavacElements instance(Context context) {
-        JavacElements instance = context.get(KEY);
-        if (instance == null) {
+        JavacElements instance = context.get(JavacElements.class);
+        if (instance == null)
             instance = new JavacElements(context);
-            context.put(KEY, instance);
-        }
         return instance;
     }
 
     /**
      * Public for use only by JavacProcessingEnvironment
      */
-    // TODO JavacElements constructor should be protected
-    public JavacElements(Context context) {
+    protected JavacElements(Context context) {
         setContext(context);
     }
 
     /**
      * Use a new context.  May be called from outside to update
      * internal state for a new annotation-processing round.
-     * This instance is *not* then registered with the new context.
      */
     public void setContext(Context context) {
+        context.put(JavacElements.class, this);
         javaCompiler = JavaCompiler.instance(context);
         syms = Symtab.instance(context);
         names = Names.instance(context);
--- a/src/share/classes/com/sun/tools/javac/model/JavacTypes.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/JavacTypes.java	Wed Nov 10 19:07:04 2010 +0000
@@ -47,32 +47,26 @@
     private Symtab syms;
     private Types types;
 
-    private static final Context.Key<JavacTypes> KEY =
-            new Context.Key<JavacTypes>();
-
     public static JavacTypes instance(Context context) {
-        JavacTypes instance = context.get(KEY);
-        if (instance == null) {
+        JavacTypes instance = context.get(JavacTypes.class);
+        if (instance == null)
             instance = new JavacTypes(context);
-            context.put(KEY, instance);
-        }
         return instance;
     }
 
     /**
      * Public for use only by JavacProcessingEnvironment
      */
-    // TODO JavacTypes constructor should be protected
-    public JavacTypes(Context context) {
+    protected JavacTypes(Context context) {
         setContext(context);
     }
 
     /**
      * Use a new context.  May be called from outside to update
      * internal state for a new annotation-processing round.
-     * This instance is *not* then registered with the new context.
      */
     public void setContext(Context context) {
+        context.put(JavacTypes.class, this);
         syms = Symtab.instance(context);
         types = Types.instance(context);
     }
@@ -103,7 +97,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/DocCommentScanner.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -2473,6 +2473,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);
@@ -2781,7 +2786,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 {
             String dc = S.docComment();
             int pos = S.pos();
--- a/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/ParserFactory.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -47,48 +47,6 @@
 
     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;
-
-        /** 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);
-        }
-
-        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():
      */
 
@@ -108,6 +66,10 @@
      */
     private boolean allowUnderscoresInLiterals;
 
+    /** Allow exotic identifiers.
+     */
+    private boolean allowExoticIdentifiers;
+
     /** The source language setting.
      */
     private Source source;
@@ -173,7 +135,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;
@@ -181,6 +143,7 @@
         allowBinaryLiterals = source.allowBinaryLiterals();
         allowHexFloats = source.allowHexFloats();
         allowUnderscoresInLiterals = source.allowBinaryLiterals();
+        allowExoticIdentifiers = source.allowExoticIdentifiers();  // for invokedynamic
     }
 
     private static final boolean hexFloatsWork = hexFloatsWork();
@@ -196,7 +159,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());
     }
 
@@ -211,7 +174,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) {
@@ -1010,6 +973,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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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,27 +157,28 @@
     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;
 
-        // Initialize services before any processors are initialzied
+        // Initialize services before any processors are initialized
         // in case processors use them.
         filer = new JavacFiler(context);
         messager = new JavacMessager(context, this);
-        elementUtils = new JavacElements(context);
-        typeUtils = new JavacTypes(context);
+        elementUtils = JavacElements.instance(context);
+        typeUtils = JavacTypes.instance(context);
         processorOptions = initProcessorOptions(context);
         unmatchedProcessorOptions = initUnmatchedProcessorOptions();
         messages = JavacMessages.instance(context);
@@ -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();
     }
 
@@ -818,6 +830,7 @@
 
             compiler = JavaCompiler.instance(context);
             log = Log.instance(context);
+            log.deferDiagnostics = true;
 
             // the following is for the benefit of JavacProcessingEnvironment.getContext()
             JavacProcessingEnvironment.this.context = context;
@@ -848,13 +861,10 @@
 
         /** Create a new round. */
         private Round(Round prev,
-                Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles)
-                throws IOException {
+                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);
 
@@ -882,8 +892,7 @@
         }
 
         /** Create the next round to be used. */
-        Round next(Set<JavaFileObject> newSourceFiles, Map<String, JavaFileObject> newClassFiles)
-                throws IOException {
+        Round next(Set<JavaFileObject> newSourceFiles, Map<String, JavaFileObject> newClassFiles) {
             try {
                 return new Round(this, newSourceFiles, newClassFiles);
             } finally {
@@ -919,10 +928,24 @@
 
         /** Return whether or not an unrecoverable error has occurred. */
         boolean unrecoverableError() {
-            return log.unrecoverableError
-                    || messager.errorRaised()
-                    || (werror && log.nwarnings > 0)
-                    || (fatalErrors && log.nerrors > 0);
+            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
@@ -938,7 +961,7 @@
         }
 
         /** Enter a set of generated class files. */
-        List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
+        private List<ClassSymbol> enterClassFiles(Map<String, JavaFileObject> classFiles) {
             ClassReader reader = ClassReader.instance(context);
             Names names = Names.instance(context);
             List<ClassSymbol> list = List.nil();
@@ -965,7 +988,7 @@
         }
 
         /** Enter a set of syntax trees. */
-        void enterTrees(List<JCCompilationUnit> roots) {
+        private void enterTrees(List<JCCompilationUnit> roots) {
             compiler.enterTrees(roots);
         }
 
@@ -995,13 +1018,13 @@
             }
         }
 
-        /** Update the processing state for the current context. */
-        private void updateProcessingState() {
-            filer.newRound(context);
-            messager.newRound(context);
-
-            elementUtils.setContext(context);
-            typeUtils.setContext(context);
+        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);
         }
 
         /** Print info about this round. */
@@ -1066,12 +1089,23 @@
             JavaCompiler nextCompiler = JavaCompiler.instance(next);
             nextCompiler.initRound(oldCompiler);
 
+            filer.newRound(next);
+            messager.newRound(next);
+            elementUtils.setContext(next);
+            typeUtils.setContext(next);
+
             JavacTaskImpl task = context.get(JavacTaskImpl.class);
             if (task != null) {
                 next.put(JavacTaskImpl.class, task);
                 task.updateContext(next);
             }
 
+            JavacTrees trees = context.get(JavacTrees.class);
+            if (trees != null) {
+                next.put(JavacTrees.class, trees);
+                trees.updateContext(next);
+            }
+
             context.clear();
             return next;
         }
@@ -1083,8 +1117,7 @@
     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);
@@ -1107,6 +1140,8 @@
             errorStatus = round.unrecoverableError();
             moreToDo = moreToDo();
 
+            round.showDiagnostics(errorStatus || showResolveErrors);
+
             // Set up next round.
             // Copy mutable collections returned from filer.
             round = round.next(
@@ -1121,6 +1156,7 @@
 
         // run last round
         round.run(true, errorStatus);
+        round.showDiagnostics(true);
 
         filer.warnIfUnclosedFiles();
         warnIfUnmatchedOptions();
@@ -1184,13 +1220,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) {
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Nov 10 19:07:04 2010 +0000
@@ -93,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.assign.val.to.final.var=\
     cannot assign a value to final variable {0}
 compiler.err.cant.deref=\
@@ -128,6 +130,11 @@
 compiler.err.no.superclass=\
     {0} has no superclass
 
+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
 
@@ -550,6 +557,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
 
 #####
 
@@ -1068,11 +1077,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\
@@ -1088,6 +1097,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".
@@ -1225,6 +1244,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
 ########################################
@@ -1240,6 +1263,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/legacy.properties	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Nov 10 19:07:04 2010 +0000
@@ -340,6 +340,7 @@
     public abstract int getTag();
 
     /** Convert a tree to a pretty-printed string. */
+    @Override
     public String toString() {
         StringWriter s = new StringWriter();
         try {
@@ -375,6 +376,7 @@
 
     /** Return a shallow copy of this tree.
      */
+    @Override
     public Object clone() {
         try {
             return super.clone();
@@ -587,7 +589,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Wed Nov 10 19:07:04 2010 +0000
@@ -501,6 +501,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);
@@ -633,6 +637,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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);
+        }
+        if (d.isMultiline() && getConfiguration().getVisible().contains(DiagnosticPart.SUBDIAGNOSTICS)) {
+            currentIndentation += getConfiguration().getIndentation(DiagnosticPart.SUBDIAGNOSTICS);
                 for (String sub : formatSubdiagnostics(d, l)) {
-                    buf.append("\n" + sub);
-                }
+                    buf.append("\n" + indent(sub, currentIndentation));
             }
-            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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/FatalError.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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/Log.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Wed Nov 10 19:07:04 2010 +0000
@@ -27,17 +27,22 @@
 
 import java.io.*;
 import java.util.Arrays;
+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.api.DiagnosticFormatter;
+import com.sun.tools.javac.main.OptionName;
 import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.api.DiagnosticFormatter;
 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.
  *
@@ -110,6 +115,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
@@ -121,14 +132,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.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);
@@ -142,7 +153,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) {
@@ -204,12 +215,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.
@@ -347,12 +352,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 (deferDiagnostics) {
+            deferredDiagnostics.add(diagnostic);
+            return;
+        }
+
         if (expectDiagKeys != null)
             expectDiagKeys.remove(diagnostic.getCode());
 
--- a/src/share/classes/com/sun/tools/javac/util/Names.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Names.java	Wed Nov 10 19:07:04 2010 +0000
@@ -103,7 +103,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;
@@ -116,6 +115,7 @@
     public final Name value;
     public final Name getMessage;
     public final Name getClass;
+    public final Name invoke;  //allowTransitionalJSR292 only
     public final Name TYPE;
     public final Name TYPE_USE;
     public final Name TYPE_PARAMETER;
@@ -215,7 +215,6 @@
         RuntimeInvisibleTypeAnnotations = fromString("RuntimeInvisibleTypeAnnotations");
         RuntimeVisibleParameterAnnotations = fromString("RuntimeVisibleParameterAnnotations");
         RuntimeInvisibleParameterAnnotations = fromString("RuntimeInvisibleParameterAnnotations");
-        PolymorphicSignature = fromString("PolymorphicSignature");
         Value = fromString("Value");
         EnclosingMethod = fromString("EnclosingMethod");
 
@@ -230,6 +229,7 @@
         value = fromString("value");
         getMessage = fromString("getMessage");
         getClass = fromString("getClass");
+        invoke = fromString("invoke");  //allowTransitionalJSR292 only
 
         TYPE = fromString("TYPE");
         TYPE_USE = fromString("TYPE_USE");
@@ -271,7 +271,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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Options.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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/JNI.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/JNI.java	Wed Nov 10 19:07:04 2010 +0000
@@ -59,72 +59,76 @@
     }
 
     public void write(OutputStream o, TypeElement clazz) throws Util.Exit {
-        String cname = mangler.mangle(clazz.getQualifiedName(), Mangle.Type.CLASS);
-        PrintWriter pw = wrapWriter(o);
-        pw.println(guardBegin(cname));
-        pw.println(cppGuardBegin());
+        try {
+            String cname = mangler.mangle(clazz.getQualifiedName(), Mangle.Type.CLASS);
+            PrintWriter pw = wrapWriter(o);
+            pw.println(guardBegin(cname));
+            pw.println(cppGuardBegin());
 
-        /* Write statics. */
-        List<VariableElement> classfields = getAllFields(clazz);
+            /* Write statics. */
+            List<VariableElement> classfields = getAllFields(clazz);
 
-        for (VariableElement v: classfields) {
-            if (!v.getModifiers().contains(Modifier.STATIC))
-                continue;
-            String s = null;
-            s = defineForStatic(clazz, v);
-            if (s != null) {
-                pw.println(s);
+            for (VariableElement v: classfields) {
+                if (!v.getModifiers().contains(Modifier.STATIC))
+                    continue;
+                String s = null;
+                s = defineForStatic(clazz, v);
+                if (s != null) {
+                    pw.println(s);
+                }
             }
-        }
 
-        /* Write methods. */
-        List<ExecutableElement> classmethods = ElementFilter.methodsIn(clazz.getEnclosedElements());
-        for (ExecutableElement md: classmethods) {
-            if(md.getModifiers().contains(Modifier.NATIVE)){
-                TypeMirror mtr = types.erasure(md.getReturnType());
-                String sig = signature(md);
-                TypeSignature newtypesig = new TypeSignature(elems);
-                CharSequence methodName = md.getSimpleName();
-                boolean longName = false;
-                for (ExecutableElement md2: classmethods) {
-                    if ((md2 != md)
-                        && (methodName.equals(md2.getSimpleName()))
-                        && (md2.getModifiers().contains(Modifier.NATIVE)))
-                        longName = true;
+            /* Write methods. */
+            List<ExecutableElement> classmethods = ElementFilter.methodsIn(clazz.getEnclosedElements());
+            for (ExecutableElement md: classmethods) {
+                if(md.getModifiers().contains(Modifier.NATIVE)){
+                    TypeMirror mtr = types.erasure(md.getReturnType());
+                    String sig = signature(md);
+                    TypeSignature newtypesig = new TypeSignature(elems);
+                    CharSequence methodName = md.getSimpleName();
+                    boolean longName = false;
+                    for (ExecutableElement md2: classmethods) {
+                        if ((md2 != md)
+                            && (methodName.equals(md2.getSimpleName()))
+                            && (md2.getModifiers().contains(Modifier.NATIVE)))
+                            longName = true;
 
+                    }
+                    pw.println("/*");
+                    pw.println(" * Class:     " + cname);
+                    pw.println(" * Method:    " +
+                               mangler.mangle(methodName, Mangle.Type.FIELDSTUB));
+                    pw.println(" * Signature: " + newtypesig.getTypeSignature(sig, mtr));
+                    pw.println(" */");
+                    pw.println("JNIEXPORT " + jniType(mtr) +
+                               " JNICALL " +
+                               mangler.mangleMethod(md, clazz,
+                                                   (longName) ?
+                                                   Mangle.Type.METHOD_JNI_LONG :
+                                                   Mangle.Type.METHOD_JNI_SHORT));
+                    pw.print("  (JNIEnv *, ");
+                    List<? extends VariableElement> paramargs = md.getParameters();
+                    List<TypeMirror> args = new ArrayList<TypeMirror>();
+                    for (VariableElement p: paramargs) {
+                        args.add(types.erasure(p.asType()));
+                    }
+                    if (md.getModifiers().contains(Modifier.STATIC))
+                        pw.print("jclass");
+                    else
+                        pw.print("jobject");
+
+                    for (TypeMirror arg: args) {
+                        pw.print(", ");
+                        pw.print(jniType(arg));
+                    }
+                    pw.println(");" + lineSep);
                 }
-                pw.println("/*");
-                pw.println(" * Class:     " + cname);
-                pw.println(" * Method:    " +
-                           mangler.mangle(methodName, Mangle.Type.FIELDSTUB));
-                pw.println(" * Signature: " + newtypesig.getTypeSignature(sig, mtr));
-                pw.println(" */");
-                pw.println("JNIEXPORT " + jniType(mtr) +
-                           " JNICALL " +
-                           mangler.mangleMethod(md, clazz,
-                                               (longName) ?
-                                               Mangle.Type.METHOD_JNI_LONG :
-                                               Mangle.Type.METHOD_JNI_SHORT));
-                pw.print("  (JNIEnv *, ");
-                List<? extends VariableElement> paramargs = md.getParameters();
-                List<TypeMirror> args = new ArrayList<TypeMirror>();
-                for (VariableElement p: paramargs) {
-                    args.add(types.erasure(p.asType()));
-                }
-                if (md.getModifiers().contains(Modifier.STATIC))
-                    pw.print("jclass");
-                else
-                    pw.print("jobject");
-
-                for (TypeMirror arg: args) {
-                    pw.print(", ");
-                    pw.print(jniType(arg));
-                }
-                pw.println(");" + lineSep);
             }
+            pw.println(cppGuardEnd());
+            pw.println(guardEnd(cname));
+        } catch (TypeSignature.SignatureException e) {
+            util.error("jni.sigerror", e.getMessage());
         }
-        pw.println(cppGuardEnd());
-        pw.println(guardEnd(cname));
     }
 
 
--- a/src/share/classes/com/sun/tools/javah/JavahTask.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/JavahTask.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -46,9 +46,9 @@
 
 import javax.annotation.processing.AbstractProcessor;
 import javax.annotation.processing.Messager;
+import javax.annotation.processing.ProcessingEnvironment;
 import javax.annotation.processing.RoundEnvironment;
 import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
 
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.ExecutableElement;
@@ -71,6 +71,9 @@
 import javax.tools.StandardJavaFileManager;
 import javax.tools.StandardLocation;
 import javax.tools.ToolProvider;
+import static javax.tools.Diagnostic.Kind.*;
+
+import com.sun.tools.javac.code.Symbol.CompletionFailure;
 
 /**
  * Javah generates support files for native methods.
@@ -173,7 +176,7 @@
             }
         },
 
-        new Option(false, "-help", "--help", "-?") {
+        new Option(false, "-h", "-help", "--help", "-?") {
             void process(JavahTask task, String opt, String arg) {
                 task.help = true;
             }
@@ -233,6 +236,15 @@
                 task.doubleAlign = true;
             }
         },
+
+        new HiddenOption(false) {
+            boolean matches(String opt) {
+                return opt.startsWith("-XD");
+            }
+            void process(JavahTask task, String opt, String arg) {
+                task.javac_extras.add(opt);
+            }
+        },
     };
 
     JavahTask() {
@@ -326,6 +338,8 @@
         } catch (InternalError e) {
             diagnosticListener.report(createDiagnostic("err.internal.error", e.getMessage()));
             return 1;
+        } catch (Util.Exit e) {
+            return e.exitValue;
         } finally {
             log.flush();
         }
@@ -475,7 +489,9 @@
             ((JavahFileManager) fileManager).setIgnoreSymbolFile(true);
 
         JavaCompiler c = ToolProvider.getSystemJavaCompiler();
-        List<String> opts = Arrays.asList("-proc:only");
+        List<String> opts = new ArrayList<String>();
+        opts.add("-proc:only");
+        opts.addAll(javac_extras);
         CompilationTask t = c.getTask(log, fileManager, diagnosticListener, opts, internalize(classes), null);
         JavahProcessor p = new JavahProcessor(g);
         t.setProcessors(Collections.singleton(p));
@@ -526,15 +542,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 +561,7 @@
             }
         }
         try {
-            return versionRB.getString(key);
+            return getMessage(msgKey, "javah", versionRB.getString(versionKey));
         }
         catch (MissingResourceException e) {
             return getMessage("version.unknown", System.getProperty("java.version"));
@@ -640,6 +658,7 @@
     boolean doubleAlign;
     boolean force;
     boolean old;
+    Set<String> javac_extras = new LinkedHashSet<String>();
 
     PrintWriter log;
     JavaFileManager fileManager;
@@ -650,30 +669,45 @@
     private static final String progname = "javah";
 
     @SupportedAnnotationTypes("*")
-    @SupportedSourceVersion(SourceVersion.RELEASE_7)
     class JavahProcessor extends AbstractProcessor {
+        private Messager messager;
+
         JavahProcessor(Gen g) {
             this.g = g;
         }
 
-        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
-            Messager messager  = processingEnv.getMessager();
-            Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
-            if (classes.size() > 0) {
-                checkMethodParameters(classes);
-                g.setProcessingEnvironment(processingEnv);
-                g.setClasses(classes);
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            // since this is co-bundled with javac, we can assume it supports
+            // the latest source version
+            return SourceVersion.latest();
+        }
+
+        @Override
+        public void init(ProcessingEnvironment pEnv) {
+            super.init(pEnv);
+            messager  = processingEnv.getMessager();
+        }
 
-                try {
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            try {
+                Set<TypeElement> classes = getAllClasses(ElementFilter.typesIn(roundEnv.getRootElements()));
+                if (classes.size() > 0) {
+                    checkMethodParameters(classes);
+                    g.setProcessingEnvironment(processingEnv);
+                    g.setClasses(classes);
                     g.run();
-                } catch (ClassNotFoundException cnfe) {
-                    messager.printMessage(Diagnostic.Kind.ERROR, getMessage("class.not.found", cnfe.getMessage()));
-                } catch (IOException ioe) {
-                    messager.printMessage(Diagnostic.Kind.ERROR, getMessage("io.exception", ioe.getMessage()));
-                } catch (Util.Exit e) {
-                    exit = e;
                 }
+            } catch (CompletionFailure cf) {
+                messager.printMessage(ERROR, getMessage("class.not.found", cf.sym.getQualifiedName().toString()));
+            } catch (ClassNotFoundException cnfe) {
+                messager.printMessage(ERROR, getMessage("class.not.found", cnfe.getMessage()));
+            } catch (IOException ioe) {
+                messager.printMessage(ERROR, getMessage("io.exception", ioe.getMessage()));
+            } catch (Util.Exit e) {
+                exit = e;
             }
+
             return true;
         }
 
--- a/src/share/classes/com/sun/tools/javah/LLNI.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/LLNI.java	Wed Nov 10 19:07:04 2010 +0000
@@ -74,16 +74,21 @@
     }
 
     protected void write(OutputStream o, TypeElement clazz) throws Util.Exit {
-        String cname     = mangleClassName(clazz.getQualifiedName().toString());
-        PrintWriter pw   = wrapWriter(o);
-        fields = ElementFilter.fieldsIn(clazz.getEnclosedElements());
-        methods = ElementFilter.methodsIn(clazz.getEnclosedElements());
-        generateDeclsForClass(pw, clazz, cname);
-        // FIXME check if errors occurred on the PrintWriter and throw exception if so
+        try {
+            String cname     = mangleClassName(clazz.getQualifiedName().toString());
+            PrintWriter pw   = wrapWriter(o);
+            fields = ElementFilter.fieldsIn(clazz.getEnclosedElements());
+            methods = ElementFilter.methodsIn(clazz.getEnclosedElements());
+            generateDeclsForClass(pw, clazz, cname);
+            // FIXME check if errors occurred on the PrintWriter and throw exception if so
+        } catch (TypeSignature.SignatureException e) {
+            util.error("llni.sigerror", e.getMessage());
+        }
     }
 
     protected void generateDeclsForClass(PrintWriter pw,
-            TypeElement clazz, String cname) throws Util.Exit {
+            TypeElement clazz, String cname)
+            throws TypeSignature.SignatureException, Util.Exit {
         doneHandleTypes  = new HashSet<String>();
         /* The following handle types are predefined in "typedefs.h". Suppress
            inclusion in the output by generating them "into the blue" here. */
@@ -127,7 +132,8 @@
             .replace(innerDelim, '_');
     }
 
-    protected void forwardDecls(PrintWriter pw, TypeElement clazz) {
+    protected void forwardDecls(PrintWriter pw, TypeElement clazz)
+            throws TypeSignature.SignatureException {
         TypeElement object = elems.getTypeElement("java.lang.Object");
         if (clazz.equals(object))
             return;
@@ -403,7 +409,7 @@
 
     protected void methodSectionForClass(PrintWriter pw,
             TypeElement clazz, String cname)
-            throws Util.Exit {
+            throws TypeSignature.SignatureException, Util.Exit {
         String methods = methodDecls(clazz, cname);
 
         if (methods.length() != 0) {
@@ -418,7 +424,8 @@
         }
     }
 
-    protected String methodDecls(TypeElement clazz, String cname) throws Util.Exit {
+    protected String methodDecls(TypeElement clazz, String cname)
+            throws TypeSignature.SignatureException, Util.Exit {
 
         String res = "";
         for (ExecutableElement method: methods) {
@@ -430,7 +437,7 @@
 
     protected String methodDecl(ExecutableElement method,
                                 TypeElement clazz, String cname)
-    throws Util.Exit {
+            throws TypeSignature.SignatureException, Util.Exit {
         String res = null;
 
         TypeMirror retType = types.erasure(method.getReturnType());
@@ -474,7 +481,8 @@
     }
 
     protected final String jniMethodName(ExecutableElement method, String cname,
-                                         boolean longName) {
+                                         boolean longName)
+                throws TypeSignature.SignatureException {
         String res = "Java_" + cname + "_" + method.getSimpleName();
 
         if (longName) {
--- a/src/share/classes/com/sun/tools/javah/Mangle.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/Mangle.java	Wed Nov 10 19:07:04 2010 +0000
@@ -114,7 +114,7 @@
     }
 
     public String mangleMethod(ExecutableElement method, TypeElement clazz,
-                                      int mtype) {
+                                      int mtype) throws TypeSignature.SignatureException {
         StringBuffer result = new StringBuffer(100);
         result.append("Java_");
 
--- a/src/share/classes/com/sun/tools/javah/TypeSignature.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/TypeSignature.java	Wed Nov 10 19:07:04 2010 +0000
@@ -51,7 +51,13 @@
  * @author Sucheta Dambalkar
  */
 
-public class TypeSignature{
+public class TypeSignature {
+    static class SignatureException extends Exception {
+        private static final long serialVersionUID = 1L;
+        SignatureException(String reason) {
+            super(reason);
+        }
+    }
 
     Elements elems;
 
@@ -78,14 +84,15 @@
     /*
      * Returns the type signature of a field according to JVM specs
      */
-    public String getTypeSignature(String javasignature){
+    public String getTypeSignature(String javasignature) throws SignatureException {
         return getParamJVMSignature(javasignature);
     }
 
     /*
      * Returns the type signature of a method according to JVM specs
      */
-    public String getTypeSignature(String javasignature, TypeMirror returnType){
+    public String getTypeSignature(String javasignature, TypeMirror returnType)
+            throws SignatureException {
         String signature = null; //Java type signature.
         String typeSignature = null; //Internal type signature.
         List<String> params = new ArrayList<String>(); //List of parameters.
@@ -166,7 +173,7 @@
     /*
      * Returns internal signature of a parameter.
      */
-    private String getParamJVMSignature(String paramsig) {
+    private String getParamJVMSignature(String paramsig) throws SignatureException {
         String paramJVMSig = "";
         String componentType ="";
 
@@ -197,7 +204,7 @@
     /*
      * Returns internal signature of a component.
      */
-    private String getComponentType(String componentType){
+    private String getComponentType(String componentType) throws SignatureException {
 
         String JVMSig = "";
 
@@ -216,8 +223,7 @@
                     TypeElement classNameDoc = elems.getTypeElement(componentType);
 
                     if(classNameDoc == null){
-                        System.out.println("Invalid class type for " + componentType);
-                        new Exception().printStackTrace();
+                        throw new SignatureException(componentType);
                     }else {
                         String classname = classNameDoc.getQualifiedName().toString();
                         String newclassname = classname.replace('.', '/');
--- a/src/share/classes/com/sun/tools/javah/resources/l10n.properties	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javah/resources/l10n.properties	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -45,6 +45,8 @@
         Can''t mix options -jni and -llni.  Try -help.
 jni.no.stubs=\
         JNI does not require stubs, please refer to the JNI documentation.
+jni.sigerror=\
+        Cannot determine signature for {0}
 dir.file.mixed=\
         Can''t mix options -d and -o.  Try -help.
 no.classes.specified=\
@@ -94,7 +96,7 @@
 \  -d <dir>                 Output directory
 main.opt.v=\
 \  -v  -verbose             Enable verbose output
-main.opt.help=\
+main.opt.h=\
 \  -h  --help  -?           Print this message
 main.opt.version=\
 \  -version                 Print version information
@@ -113,7 +115,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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javap/CodeWriter.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/com/sun/tools/javap/SourceWriter.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/src/share/classes/javax/tools/ToolProvider.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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);
+        }
+    }
+
+
+    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;
+        }
     }
 
-    /**
-     * 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 <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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/6302184/T6302184.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,4 +1,7 @@
 
+/**
+ * This is a test that uses ISO 8859 encoding.
+ */
 class T6302184 {
     
     T6302184() {
--- a/test/tools/javac/6304921/TestLog.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/6304921/TestLog.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/6758789/T6758789a.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/6840059/T6840059.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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
--- a/test/tools/javac/6857948/T6857948.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/6857948/T6857948.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,3 +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: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, null
+T6857948.java:16:50: compiler.err.cant.apply.symbol.1: kindname.constructor, Foo, java.lang.String, compiler.misc.no.args, kindname.class, Foo, (compiler.misc.arg.length.mismatch)
 2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6863465/T6863465a.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/CyclicInheritance.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_1.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234a_2.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6722234/T6722234c.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6799605/T6799605.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6862608/T6862608a.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,3 +1,3 @@
-T6862608a.java:19:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.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>
+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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/Diagnostics/6862608/T6862608b.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/InterfaceAssert.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/NameCollision.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/T6326754.out	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Tue Sep 14 11:37:19 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;
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T6458749.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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/T6705935.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/T6705935.java	Wed Nov 10 19:07:04 2010 +0000
@@ -31,6 +31,8 @@
 import java.util.*;
 import javax.tools.*;
 import com.sun.tools.javac.file.*;
+import com.sun.tools.javac.file.ZipArchive.ZipFileObject;
+import com.sun.tools.javac.file.ZipFileIndexArchive.ZipFileIndexFileObject;
 
 public class T6705935 {
     public static void main(String... args) throws Exception {
@@ -43,11 +45,22 @@
             java_home = java_home.getParentFile();
 
         JavaCompiler c = ToolProvider.getSystemJavaCompiler();
-        JavaFileManager fm = c.getStandardFileManager(null, null, null);
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+        //System.err.println("platform class path: " + asList(fm.getLocation(StandardLocation.PLATFORM_CLASS_PATH)));
+
         for (JavaFileObject fo: fm.list(StandardLocation.PLATFORM_CLASS_PATH,
                                         "java.lang",
                                         Collections.singleton(JavaFileObject.Kind.CLASS),
                                         false)) {
+            test++;
+
+            if (!(fo instanceof ZipFileObject || fo instanceof ZipFileIndexFileObject)) {
+                System.out.println("Skip " + fo.getClass().getSimpleName() + " " + fo.getName());
+                skip++;
+                continue;
+            }
+
+            //System.err.println(fo.getName());
             String p = fo.getName();
             int bra = p.indexOf("(");
             int ket = p.indexOf(")");
@@ -61,5 +74,26 @@
                 throw new Exception("bad path: " + p);
 
         }
+
+        if (test == 0)
+            throw new Exception("no files found");
+
+        if (skip == 0)
+            System.out.println(test + " files found");
+        else
+            System.out.println(test + " files found, " + skip + " files skipped");
+
+        if (test == skip)
+            System.out.println("Warning: all files skipped; no platform classes found in zip files.");
     }
+
+    private <T> List<T> asList(Iterable<? extends T> items) {
+        List<T> list = new ArrayList<T>();
+        for (T item: items)
+            list.add(item);
+        return list;
+     }
+
+    private int skip;
+    private int test;
 }
--- a/test/tools/javac/T6855236.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/T6855236.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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/T6985181.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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	Wed Nov 10 19:07:04 2010 +0000
@@ -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);
+                        }
+                        if (errors > 0) throw new AssertionError();
+                    }
+                }
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(OptKind ok, boolean sr, boolean cr, boolean rr) throws Exception {
+        count++;
+        System.err.println("Test " + count + ": ok:" + ok + " sr:" + sr + " cr:" + cr + " rr:" + rr);
+
+        StringBuilder sb = new StringBuilder();
+
+        // create annotated package statement with all combinations of retention policy
+        if (sr) sb.append("@SR\n");
+        if (cr) sb.append("@CR\n");
+        if (rr) sb.append("@RR\n");
+        sb.append("package p;\n");
+        sb.append("\n");
+
+        sb.append("import java.lang.annotation.*;\n");
+        sb.append("@Retention(RetentionPolicy.SOURCE)  @interface SR { }\n");
+        sb.append("@Retention(RetentionPolicy.CLASS)   @interface CR { }\n");
+        sb.append("@Retention(RetentionPolicy.RUNTIME) @interface RR { }\n");
+
+        // test specific tmp directory
+        File tmpDir = new File("tmp.test" + count);
+        File classesDir = new File(tmpDir, "classes");
+        classesDir.mkdirs();
+        File pkginfo_java = new File(new File(tmpDir, "src"), "package-info.java");
+        writeFile(pkginfo_java, sb.toString());
+
+        // build up list of options and files to be compiled
+        List<String> opts = new ArrayList<String>();
+        List<File> files = new ArrayList<File>();
+
+        opts.add("-d");
+        opts.add(classesDir.getPath());
+        if (ok.opt != null)
+            opts.add(ok.opt);
+        //opts.add("-verbose");
+        files.add(pkginfo_java);
+
+        compile(opts, files);
+
+        File pkginfo_class = new File(new File(classesDir, "p"), "package-info.class");
+        boolean exists = pkginfo_class.exists();
+
+        boolean expected;
+        switch (ok) {
+            case ALWAYS:
+                expected = true;
+                break;
+
+            case LEGACY:
+            case NONE:
+                expected = (sr || cr || rr ); // any annotation
+                break;
+
+            case NONEMPTY:
+                expected = (cr || rr ); // any annotation in class file
+                break;
+
+            default:
+                throw new IllegalStateException();
+        }
+
+        if (exists && !expected)
+            error("package-info.class found but not expected");
+        if (!exists && expected)
+            error("package-info.class expected but not found");
+    }
+
+    /** Compile files with options provided. */
+    void compile(List<String> opts, List<File> files) throws Exception {
+        System.err.println("javac: " + opts + " " + files);
+        List<String> args = new ArrayList<String>();
+        args.addAll(opts);
+        for (File f: files)
+            args.add(f.getPath());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw);
+        pw.flush();
+        if (sw.getBuffer().length() > 0)
+            System.err.println(sw.toString());
+        if (rc != 0)
+            throw new Exception("compilation failed: rc=" + rc);
+    }
+
+    /** Write a file with a given body. */
+    void writeFile(File f, String body) throws Exception {
+        if (f.getParentFile() != null)
+            f.getParentFile().mkdirs();
+        Writer out = new FileWriter(f);
+        try {
+            out.write(body);
+        } finally {
+            out.close();
+        }
+    }
+
+    /** Report an error. */
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    /** Test case counter. */
+    int count;
+
+    /** Number of errors found. */
+    int errors;
+}
--- a/test/tools/javac/api/6406133/Erroneous.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/api/6406133/Erroneous.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,4 +1,26 @@
+/*
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
 @Deprecated
-class A {
-    class A {}
+class A extends Missing {
 }
--- a/test/tools/javac/api/T6392782.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/api/T6392782.java	Wed Nov 10 19:07:04 2010 +0000
@@ -47,12 +47,12 @@
         check(scanner, 6, scanner.scan(trees, null));
 
         CountNodes nodeCounter = new CountNodes();
-        // 383 nodes with the regular parser; 384 nodes with EndPosParser
-        // We automatically swith to EndPosParser when calling JavacTask.parse()
-        check(nodeCounter, 384, nodeCounter.scan(trees, null));
+        // 359 nodes with the regular parser; 360 nodes with EndPosParser
+        // We automatically switch to EndPosParser when calling JavacTask.parse()
+        check(nodeCounter, 360, nodeCounter.scan(trees, null));
 
         CountIdentifiers idCounter = new CountIdentifiers();
-        check(idCounter, 106, idCounter.scan(trees, null));
+        check(idCounter, 107, idCounter.scan(trees, null));
     }
 
     private static void check(TreeScanner<?,?> scanner, int expect, int found) {
@@ -73,10 +73,11 @@
         }
     }
 
-    // example from TreeScanner javadoc
     static class CountNodes extends TreeScanner<Integer,Void> {
         @Override
         public Integer scan(Tree node, Void p) {
+            if (node == null)
+                return 0;
             Integer n = super.scan(node, p);
             return (n == null ? 0 : n) + 1;
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/TestContainTypes.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,216 @@
+/*
+ * 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 6981185
+ * @summary  com.sun.tools.model.JavacTypes.contains() calls Type.contains instead of Types.containsType
+ * @run main TestContainTypes
+ */
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.DeclaredType;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+
+public class TestContainTypes {
+
+    enum ClassType {
+        OBJECT("Object"),
+        NUMBER("Number"),
+        INTEGER("Integer"),
+        STRING("String");
+
+        String classStub;
+
+        ClassType(String classStub) {
+            this.classStub = classStub;
+        }
+
+        boolean subtypeOf(ClassType that) {
+            switch (that) {
+                case OBJECT: return true;
+                case NUMBER: return this == NUMBER || this == INTEGER;
+                case INTEGER: return this == INTEGER;
+                case STRING: return this == STRING;
+                default: throw new AssertionError("Bad type kind in subtyping test");
+            }
+        }
+    }
+
+    enum ParameterType {
+        INVARIANT("List<#1>"),
+        COVARIANT("List<? extends #1>"),
+        CONTRAVARIANT("List<? super #1>"),
+        BIVARIANT("List<?>");
+
+        String paramTypeStub;
+
+        ParameterType(String paramTypeStub) {
+            this.paramTypeStub = paramTypeStub;
+        }
+
+        String instantiate(ClassType ct) {
+            return paramTypeStub.replace("#1", ct.classStub);
+        }
+
+        static boolean contains(ParameterType pt1, ClassType ct1,
+                ParameterType pt2, ClassType ct2) {
+            switch (pt1) {
+                case INVARIANT: return (pt2 == INVARIANT && ct1 == ct2) ||
+                                           (pt2 == CONTRAVARIANT && ct1 == ct2 && ct1 == ClassType.OBJECT);
+                case COVARIANT: return ((pt2 == INVARIANT || pt2 == COVARIANT) &&
+                                            ct2.subtypeOf(ct1)) ||
+                                            (ct1 == ClassType.OBJECT);
+                case CONTRAVARIANT: return (pt2 == INVARIANT || pt2 == CONTRAVARIANT) &&
+                                            ct1.subtypeOf(ct2);
+                case BIVARIANT: return true;
+                default: throw new AssertionError("Bad type kind in containment test");
+            }
+        }
+    }
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        final static String sourceStub =
+                        "import java.util.List;\n" +
+                        "@interface ToCheck {}\n" +
+                        "class Test {\n" +
+                        "   @ToCheck void test(#A a, #B b) {}\n" +
+                        "}\n";
+
+        String source;
+
+        public JavaSource(String typeA, String typeB) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = sourceStub.replace("#A", typeA).replace("#B", typeB);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (ClassType ctA : ClassType.values()) {
+            for (ParameterType ptA : ParameterType.values()) {
+                for (ClassType ctB : ClassType.values()) {
+                    for (ParameterType ptB : ParameterType.values()) {
+                        compileAndCheck(ptA, ctA, ptB, ctB);
+                    }
+                }
+            }
+        }
+    }
+
+    static void compileAndCheck(ParameterType ptA, ClassType ctA, ParameterType ptB, ClassType ctB) throws Exception {
+        JavaSource source = new JavaSource(ptA.instantiate(ctA), ptB.instantiate(ctB));
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, null,
+                null, null, Arrays.asList(source));
+        ct.setProcessors(Arrays.asList(new ContainTypesTester(ParameterType.contains(ptA, ctA, ptB, ctB), source)));
+        System.err.println("A = " + ptA +" / " + ptA.instantiate(ctA));
+        System.err.println("B = " + ptB +" / " + ptB.instantiate(ctB));
+        System.err.println("Source = " + source.source);
+        ct.analyze();
+    }
+
+    @SupportedSourceVersion(SourceVersion.RELEASE_7)
+    static class ContainTypesTester extends AbstractProcessor {
+
+        boolean expected;
+        JavaSource source;
+
+        ContainTypesTester(boolean expected, JavaSource source) {
+            this.expected = expected;
+            this.source = source;
+        }
+
+        @Override
+        public Set<String> getSupportedAnnotationTypes() {
+            Set<String> supportedAnnos = new HashSet();
+            supportedAnnos.add("*");
+            return supportedAnnos;
+        }
+
+        private void error(String msg) {
+            System.err.println(source.source);
+            throw new AssertionError(msg);
+        }
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.getRootElements().size() == 0) {
+                return true;
+            }
+            if (annotations.isEmpty() || annotations.size() > 1) {
+                error("no anno found/wrong number of annotations found: " + annotations.size());
+            }
+            TypeElement anno = (TypeElement)annotations.toArray()[0];
+            Set<? extends Element> annoElems = roundEnv.getElementsAnnotatedWith(anno);
+            if (annoElems.isEmpty() || annoElems.size() > 1) {
+                error("no annotated element found/wrong number of annotated elements found: " + annoElems.size());
+            }
+            Element annoElement = (Element)annoElems.toArray()[0];
+            if (!(annoElement instanceof ExecutableElement)) {
+                error("annotated element must be a method");
+            }
+            ExecutableElement method = (ExecutableElement)annoElement;
+            if (method.getParameters().size() != 2) {
+                error("annotated method must have 2 arguments");
+            }
+            DeclaredType d1 = (DeclaredType)method.getParameters().get(0).asType();
+            DeclaredType d2 = (DeclaredType)method.getParameters().get(1).asType();
+            if (d1.getTypeArguments().size() != 1 ||
+                    d1.getTypeArguments().size() != 1) {
+                error("parameter type must be generic in one type-variable");
+            }
+            TypeMirror t1 = d1.getTypeArguments().get(0);
+            TypeMirror t2 = d2.getTypeArguments().get(0);
+
+            if (processingEnv.getTypeUtils().contains(t1, t2) != expected) {
+                error("bad type containment result\n" +
+                        "t1 : " + t1 +"\n" +
+                        "t2 : " + t2 +"\n" +
+                        "expected answer : " + expected +"\n");
+            }
+            return true;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/TestGetElement.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,235 @@
+/*
+ * 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 6930507
+ * @summary Symbols for anonymous and local classes made too late for use by java tree API
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.*;
+import javax.tools.Diagnostic;
+import static javax.lang.model.util.ElementFilter.*;
+
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+
+@SupportedOptions({"test", "last"})
+@SupportedAnnotationTypes("*")
+public class TestGetElement extends AbstractProcessor {
+    public static void main(String... args) throws Exception {
+        new TestGetElement().run();
+    }
+
+    public TestGetElement() { }
+
+    public void run() throws Exception {
+        final String testSrc = System.getProperty("test.src");
+        final String testClasses = System.getProperty("test.classes");
+        final String myClassName = getClass().getName();
+        final String mySrc = new File(testSrc, myClassName + ".java").getPath();
+
+        final int NUM_TESTS = 90; // #decls in this source file
+        for (int i = 1; i <= NUM_TESTS; i++) {
+            System.err.println("test " + i);
+            File testDir = new File("test" + i);
+            File classesDir = new File(testDir, "classes");
+            classesDir.mkdirs();
+            String[] args = {
+                "-d", classesDir.getPath(),
+                "-processorpath", testClasses,
+                "-processor", myClassName,
+                "-proc:only",
+                "-Atest=" + i,
+                "-Alast=" + (i == NUM_TESTS),
+                mySrc
+            };
+
+//            System.err.println("compile: " + Arrays.asList(args));
+
+            StringWriter sw = new StringWriter();
+            PrintWriter pw = new PrintWriter(sw);
+            int rc = com.sun.tools.javac.Main.compile(args, pw);
+            pw.close();
+            String out = sw.toString();
+            if (out != null)
+                System.err.println(out);
+            if (rc != 0) {
+                System.err.println("compilation failed: rc=" + rc);
+                errors++;
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+
+    int errors;
+
+    public boolean process(Set<? extends TypeElement> annotations,
+                           RoundEnvironment roundEnvironment)
+    {
+        if (roundEnvironment.processingOver())
+            return true;
+
+        Map<String,String> options = processingEnv.getOptions();
+        int test = Integer.parseInt(options.get("test"));
+        boolean _last = Boolean.parseBoolean(options.get("last"));
+
+        Trees trees = Trees.instance(processingEnv);
+        Scanner scanner = new Scanner(trees, _last);
+        int nelems = 0;
+        for (TypeElement e : typesIn(roundEnvironment.getRootElements())) {
+            nelems += scanner.scan(trees.getPath(e), test);
+        }
+
+        Messager m = processingEnv.getMessager();
+        int EXPECT = 1;
+        if (nelems != EXPECT) {
+            m.printMessage(Diagnostic.Kind.ERROR,
+                    "Unexpected number of elements found: " + nelems + " expected: " + EXPECT);
+        }
+        return true;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    class Scanner extends TreePathScanner<Integer,Integer> {
+        final Trees trees;
+        final boolean last;
+        int count;
+
+        Scanner(Trees trees, boolean last) {
+            this.trees = trees;
+            this.last = last;
+        }
+
+        @Override
+        public Integer visitClass(ClassTree tree, Integer test) {
+            return reduce(check(test), super.visitClass(tree, test));
+        }
+
+        @Override
+        public Integer visitMethod(MethodTree tree, Integer test) {
+            return reduce(check(test), super.visitMethod(tree, test));
+        }
+
+        @Override
+        public Integer visitVariable(VariableTree tree, Integer test) {
+            return reduce(check(test), super.visitVariable(tree, test));
+        }
+
+        @Override
+        public Integer reduce(Integer i1, Integer i2) {
+            if (i1 == null || i1.intValue() == 0)
+                return i2;
+            if (i2 == null || i2.intValue() == 0)
+                return i1;
+            return (i1 + i2);
+        }
+
+        int check(int test) {
+            count++;
+
+            if (count != test)
+                return 0;
+
+            TreePath p = getCurrentPath();
+            Element e = trees.getElement(p);
+
+            String text = p.getLeaf().toString().replaceAll("\\s+", " ").trim();
+            int MAXLEN = 40;
+            if (text.length() > MAXLEN)
+                text = text.substring(0, MAXLEN - 3) + "...";
+
+            System.err.println(String.format("%3d: %-" + MAXLEN + "s -- %s",
+                    count, text,
+                    (e == null ? "null" : e.getKind() + " " + e)));
+
+            Messager m = processingEnv.getMessager();
+            if (e == null) {
+                m.printMessage(Diagnostic.Kind.ERROR, "Null element found for " + text);
+                return 0;
+            }
+
+            if (last && !e.getSimpleName().contentEquals("last")) {
+                m.printMessage(Diagnostic.Kind.ERROR, "Unexpected name in last test: "
+                        + e.getSimpleName() + ", expected: last");
+            }
+
+            return 1;
+        }
+    }
+
+    // following are all fodder for the test
+
+    class MemberClass {
+        class NestedMemberClass { }
+    }
+
+    {
+        class InnerClassInInit { }
+        Object o = new Object() { };
+    }
+
+    TestGetElement(TestGetElement unused) {
+        class InnerClassInConstr { }
+        Object o = new Object() { };
+    }
+
+    void m() {
+        class InnerClassInMethod { }
+        Object o = new Object() { };
+
+        class C {
+            class MemberClass {
+                class NestedMemberClass { }
+            }
+
+            {
+                class InnerClassInInit { }
+                Object o = new Object() { };
+            }
+
+            C(Object unused) {
+                class InnerClassInConstr { }
+                Object o = new Object() { };
+            }
+
+            void m() {
+                class InnerClassInMethod { }
+                Object o = new Object() { };
+            }
+        }
+    }
+
+    int last; // this name is verified by the test to make sure that all decls are checked
+}
--- a/test/tools/javac/api/TestJavacTaskScanner.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/api/TestJavacTaskScanner.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, 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
@@ -31,8 +31,8 @@
  */
 
 import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.parser.*; // XXX
-import com.sun.tools.javac.util.*; // XXX
+import com.sun.tools.javac.parser.*;
+import com.sun.tools.javac.util.*;
 import java.io.*;
 import java.net.*;
 import java.nio.*;
@@ -65,7 +65,7 @@
             fm.getJavaFileObjects(new File[] {file});
         StandardJavaFileManager fm = getLocalFileManager(tool, null, null);
         task = (JavacTaskImpl)tool.getTask(null, fm, null, null, null, compilationUnits);
-        task.getContext().put(Scanner.Factory.scannerFactoryKey,
+        task.getContext().put(ScannerFactory.scannerFactoryKey,
                 new MyScanner.Factory(task.getContext(), this));
         elements = task.getElements();
         types = task.getTypes();
@@ -170,34 +170,36 @@
 
 class MyScanner extends Scanner {
 
-    public static class Factory extends Scanner.Factory {
+    public static class Factory extends ScannerFactory {
         public Factory(Context context, TestJavacTaskScanner test) {
             super(context);
             this.test = test;
         }
 
         @Override
-        public Scanner newScanner(CharSequence input) {
+        public Scanner newScanner(CharSequence input, boolean keepDocComments) {
+            assert !keepDocComments;
             if (input instanceof CharBuffer) {
                 return new MyScanner(this, (CharBuffer)input, test);
             } else {
                 char[] array = input.toString().toCharArray();
-                return newScanner(array, array.length);
+                return newScanner(array, array.length, keepDocComments);
             }
         }
 
         @Override
-        public Scanner newScanner(char[] input, int inputLength) {
+        public Scanner newScanner(char[] input, int inputLength, boolean keepDocComments) {
+            assert !keepDocComments;
             return new MyScanner(this, input, inputLength, test);
         }
 
         private TestJavacTaskScanner test;
     }
-    protected MyScanner(Factory fac, CharBuffer buffer, TestJavacTaskScanner test) {
+    protected MyScanner(ScannerFactory fac, CharBuffer buffer, TestJavacTaskScanner test) {
         super(fac, buffer);
         this.test = test;
     }
-    protected MyScanner(Factory fac, char[] input, int inputLength, TestJavacTaskScanner test) {
+    protected MyScanner(ScannerFactory fac, char[] input, int inputLength, TestJavacTaskScanner test) {
         super(fac, input, inputLength);
         this.test = test;
     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/ToolProvider/HelloWorldTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,83 @@
+/*
+ * 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 6604599
+ * @summary ToolProvider should be less compiler-specific
+ */
+
+import java.io.*;
+import java.util.*;
+
+// verify that running a simple program, such as this one, does not trigger
+// the loading of ToolProvider or any com.sun.tools.javac class
+public class HelloWorldTest {
+    public static void main(String... args) throws Exception {
+        if (args.length > 0) {
+            System.err.println(Arrays.asList(args));
+            return;
+        }
+
+        new HelloWorldTest().run();
+    }
+
+    void run() throws Exception {
+        File javaHome = new File(System.getProperty("java.home"));
+        if (javaHome.getName().equals("jre"))
+            javaHome = javaHome.getParentFile();
+        File javaExe = new File(new File(javaHome, "bin"), "java");
+        String classpath = System.getProperty("java.class.path");
+
+        String[] cmd = {
+            javaExe.getPath(),
+            "-verbose:class",
+            "-classpath", classpath,
+            HelloWorldTest.class.getName(),
+            "Hello", "World"
+        };
+
+        ProcessBuilder pb = new ProcessBuilder(cmd).redirectErrorStream(true);
+        Process p = pb.start();
+        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
+        String line;
+        while ((line = r.readLine()) != null) {
+            System.err.println(line);
+            if (line.contains("javax.tools.ToolProvider") || line.contains("com.sun.tools.javac."))
+                error(">>> " + line);
+        }
+        int rc = p.waitFor();
+        if (rc != 0)
+            error("Unexpected exit code: " + rc);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/ToolProvider/ToolProviderTest1.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,82 @@
+/*
+ * 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 6604599
+ * @summary ToolProvider should be less compiler-specific
+ */
+
+import java.io.*;
+
+// verify that running accessing ToolProvider by itself does not
+// trigger loading com.sun.tools.javac.*
+public class ToolProviderTest1 {
+    public static void main(String... args) throws Exception {
+        if (args.length > 0) {
+            System.err.println(Class.forName(args[0], true, null));
+            return;
+        }
+
+        new ToolProviderTest1().run();
+    }
+
+    void run() throws Exception {
+        File javaHome = new File(System.getProperty("java.home"));
+        if (javaHome.getName().equals("jre"))
+            javaHome = javaHome.getParentFile();
+        File javaExe = new File(new File(javaHome, "bin"), "java");
+        String classpath = System.getProperty("java.class.path");
+
+        String[] cmd = {
+            javaExe.getPath(),
+            "-verbose:class",
+            "-classpath", classpath,
+            ToolProviderTest1.class.getName(),
+            "javax.tools.ToolProvider"
+        };
+
+        ProcessBuilder pb = new ProcessBuilder(cmd).redirectErrorStream(true);
+        Process p = pb.start();
+        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
+        String line;
+        while ((line = r.readLine()) != null) {
+            System.err.println(line);
+            if (line.contains("com.sun.tools.javac."))
+                error(">>> " + line);
+        }
+        int rc = p.waitFor();
+        if (rc != 0)
+            error("Unexpected exit code: " + rc);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/ToolProvider/ToolProviderTest2.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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 6604599
+ * @summary ToolProvider should be less compiler-specific
+ */
+
+import java.io.*;
+import javax.tools.*;
+
+// control for ToolProviderTest1 -- verify that using ToolProvider to
+// access the compiler does trigger loading com.sun.tools.javac.*
+public class ToolProviderTest2 {
+    public static void main(String... args) throws Exception {
+        if (args.length > 0) {
+            System.err.println(ToolProvider.getSystemJavaCompiler());
+            return;
+        }
+
+        new ToolProviderTest2().run();
+    }
+
+    void run() throws Exception {
+        File javaHome = new File(System.getProperty("java.home"));
+        if (javaHome.getName().equals("jre"))
+            javaHome = javaHome.getParentFile();
+        File javaExe = new File(new File(javaHome, "bin"), "java");
+        String classpath = System.getProperty("java.class.path");
+
+        String[] cmd = {
+            javaExe.getPath(),
+            "-verbose:class",
+            "-classpath", classpath,
+            ToolProviderTest2.class.getName(),
+            "javax.tools.ToolProvider"
+        };
+
+        ProcessBuilder pb = new ProcessBuilder(cmd).redirectErrorStream(true);
+        Process p = pb.start();
+        BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
+        String line;
+        boolean found = false;
+        while ((line = r.readLine()) != null) {
+            System.err.println(line);
+            if (line.contains("com.sun.tools.javac."))
+                found = true;
+        }
+        int rc = p.waitFor();
+        if (rc != 0)
+            error("Unexpected exit code: " + rc);
+
+        if (!found)
+            System.err.println("expected class name not found");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
--- a/test/tools/javac/diags/CheckExamples.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/CheckExamples.java	Wed Nov 10 19:07:04 2010 +0000
@@ -40,7 +40,7 @@
  *      compiler.properties bundle. A list of exceptions may be given in the
  *      not-yet.txt file. Entries on the not-yet.txt list should not be
  *      covered by examples.
- * When new keys are added to the resource buncle, it is strongly recommended
+ * When new keys are added to the resource bundle, it is strongly recommended
  * that corresponding new examples be added here, if at all practical, instead
  * of simply and lazily being added to the not-yet.txt list.
  */
--- a/test/tools/javac/diags/Example.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/Example.java	Wed Nov 10 19:07:04 2010 +0000
@@ -401,7 +401,7 @@
                 }
             }
             for (JCDiagnostic sd: d.getSubdiagnostics())
-                scanForKeys(d, keys);
+                scanForKeys(sd, keys);
         }
     }
 
--- a/test/tools/javac/diags/FileManager.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/FileManager.java	Wed Nov 10 19:07:04 2010 +0000
@@ -177,12 +177,14 @@
         }
 
         void checkRead() throws IOException {
-            if (cantRead != null && cantRead.matcher(getName()).matches())
+            String canonName = getName().replace(File.separatorChar, '/');
+            if (cantRead != null && cantRead.matcher(canonName).matches())
                 throw new IOException("FileManager: Can't read");
         }
 
         void checkWrite() throws IOException {
-            if (cantWrite != null && cantWrite.matcher(getName()).matches())
+            String canonName = getName().replace(File.separatorChar, '/');
+            if (cantWrite != null && cantWrite.matcher(canonName).matches())
                 throw new IOException("FileManager: Can't write");
         }
 
--- a/test/tools/javac/diags/examples.not-yet.txt	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/examples.not-yet.txt	Wed Nov 10 19:07:04 2010 +0000
@@ -3,7 +3,7 @@
 compiler.err.annotation.value.not.allowable.type        # cannot happen: precluded by complete type-specific tests
 compiler.err.assignment.from.super-bound                # DEAD
 compiler.err.assignment.to.extends-bound                # DEAD
-compiler.err.cant.apply.symbol.1
+compiler.err.cant.apply.symbol
 compiler.err.cant.read.file                             # (apt.JavaCompiler?)
 compiler.err.cant.select.static.class.from.param.type
 compiler.err.illegal.char.for.encoding
@@ -43,7 +43,6 @@
 compiler.err.unexpected.type
 compiler.err.unknown.enum.constant                      # in bad class file
 compiler.err.unsupported.cross.fp.lit                   # Scanner: host system dependent
-compiler.misc.arg.length.mismatch
 compiler.misc.assignment.from.super-bound
 compiler.misc.assignment.to.extends-bound
 compiler.misc.bad.class.file.header                     # bad class file
@@ -62,6 +61,7 @@
 compiler.misc.fatal.err.cant.locate.ctor                # Resolve, from Lower
 compiler.misc.fatal.err.cant.locate.field               # Resolve, from Lower
 compiler.misc.fatal.err.cant.locate.meth                # Resolve, from Lower
+compiler.misc.fatal.err.cant.close.loader               # JavacProcessingEnvironment
 compiler.misc.file.does.not.contain.package
 compiler.misc.illegal.start.of.class.file
 compiler.misc.inferred.do.not.conform.to.params         # UNUSED (hard to see if very complex inference scenario might require this though, so leaving it in, as per JLS3)
@@ -72,7 +72,6 @@
 compiler.misc.kindname.type.variable
 compiler.misc.kindname.type.variable.bound
 compiler.misc.kindname.value
-compiler.misc.no.conforming.assignment.exists
 compiler.misc.non.denotable.type
 compiler.misc.no.unique.minimal.instance.exists
 compiler.misc.resume.abort                              # prompt for a response
@@ -113,3 +112,4 @@
 compiler.warn.unchecked.assign                          # DEAD, replaced by compiler.misc.unchecked.assign
 compiler.warn.unchecked.cast.to.type                    # DEAD, replaced by compiler.misc.unchecked.cast.to.type
 compiler.warn.unexpected.archive.file                   # Paths: zip file with unknown extn
+compiler.warn.wrong.target.for.polymorphic.signature.definition     # Transitional 292
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/ExplicitParamsDoNotConformToBounds.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.explicit.param.do.not.conform.to.bounds
+
+class ExplicitParamsDoNotConformToBounds {
+    <X extends Number> void m() {}
+    { this.<String>m(); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/InapplicableSymbols.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbols
+// key: compiler.misc.arg.length.mismatch
+// key: compiler.misc.inapplicable.method
+
+class ExplicitParamsDoNotConformToBounds {
+    void m(int i1) {}
+    void m(int i1, int i2) {}
+    { this.m(); }
+}
--- a/test/tools/javac/diags/examples/IncompatibleTypes1.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java	Wed Nov 10 19:07:04 2010 +0000
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.misc.incompatible.types.1
-// key: compiler.misc.no.conforming.instance.exists
+// key: compiler.misc.infer.no.conforming.instance.exists
 // key: compiler.err.prob.found.req
 
 class IncompatibleTypes1<V> {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/InferArgsLengthMismatch.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.infer.arg.length.mismatch
+
+class InferArgsLengthMismatch {
+    <X extends Number> void m(X x1, X x2) {}
+    { this.m(1); }
+}
--- a/test/tools/javac/diags/examples/KindnameConstructor.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/examples/KindnameConstructor.java	Wed Nov 10 19:07:04 2010 +0000
@@ -24,7 +24,9 @@
 // key: compiler.misc.kindname.constructor
 // key: compiler.misc.kindname.class
 // key: compiler.misc.no.args
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.arg.length.mismatch
+// key: compiler.misc.no.conforming.assignment.exists
 // key: compiler.misc.count.error.plural
 // run: backdoor
 
--- a/test/tools/javac/diags/examples/NoArgs.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/examples/NoArgs.java	Wed Nov 10 19:07:04 2010 +0000
@@ -22,7 +22,8 @@
  */
 
 // key: compiler.misc.no.args
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.arg.length.mismatch
 // run: simple
 
 class X {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/TypeParameterOnPolymorphicSignature.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.type.parameter.on.polymorphic.signature
+// key: compiler.err.unreported.exception.need.to.catch.or.throw
+
+import java.dyn.InvokeDynamic;
+
+class TypeParameterOnPolymorphicSignature {
+    { InvokeDynamic.<void>call("",123); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/UnsupportedExoticID.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.unsupported.exotic.id
+// options: -source 6
+
+class UnsupportedExoticID {
+    void m() {
+        Object #"Hello!" = null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/VarargsArgumentMismatch.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.varargs.argument.mismatch
+
+class VarargsArgumentMismatch {
+    void m(String s, Integer... is) {}
+    { this.m("1", "2", "3"); }
+}
--- a/test/tools/javac/diags/examples/WhereCaptured.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/examples/WhereCaptured.java	Wed Nov 10 19:07:04 2010 +0000
@@ -25,7 +25,8 @@
 // key: compiler.misc.where.description.captured.1
 // key: compiler.misc.where.description.typevar
 // key: compiler.misc.where.typevar
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.infer.no.conforming.assignment.exists
 // key: compiler.misc.captured.type
 // options: -XDdiags=where,simpleNames
 // run: simple
--- a/test/tools/javac/diags/examples/WhereCaptured1.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/examples/WhereCaptured1.java	Wed Nov 10 19:07:04 2010 +0000
@@ -25,7 +25,8 @@
 // key: compiler.misc.where.description.captured.1
 // key: compiler.misc.where.description.typevar
 // key: compiler.misc.where.typevar
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.infer.no.conforming.assignment.exists
 // key: compiler.misc.captured.type
 // key: compiler.misc.type.null
 // options: -XDdiags=where,simpleNames
--- a/test/tools/javac/diags/examples/WhereTypeVar.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/diags/examples/WhereTypeVar.java	Wed Nov 10 19:07:04 2010 +0000
@@ -24,7 +24,8 @@
 // key: compiler.misc.where.typevar
 // key: compiler.misc.where.description.typevar.1
 // key: compiler.misc.type.var
-// key: compiler.err.cant.apply.symbol
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.no.conforming.assignment.exists
 // options: -XDdiags=where,disambiguateTvars
 // run: simple
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/CheckAttributedTree.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,775 @@
+/*
+ * 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 com.sun.source.util.TaskEvent;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.Font;
+import java.awt.GridBagConstraints;
+import java.awt.GridBagLayout;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.JComponent;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+import javax.swing.event.CaretEvent;
+import javax.swing.event.CaretListener;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultHighlighter;
+import javax.swing.text.Highlighter;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.JCImport;
+import com.sun.tools.javac.tree.TreeInfo;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.Pair;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import javax.lang.model.element.Element;
+
+/**
+ * Utility and test program to check validity of tree positions for tree nodes.
+ * The program can be run standalone, or as a jtreg test.  In standalone mode,
+ * errors can be displayed in a gui viewer. For info on command line args,
+ * run program with no args.
+ *
+ * <p>
+ * jtreg: Note that by using the -r switch in the test description below, this test
+ * will process all java files in the langtools/test directory, thus implicitly
+ * covering any new language features that may be tested in this test suite.
+ */
+
+/*
+ * @test
+ * @bug 6970584
+ * @summary assorted position errors in compiler syntax trees
+ * @run main CheckAttributedTree -q -r -et ERRONEOUS .
+ */
+public class CheckAttributedTree {
+    /**
+     * Main entry point.
+     * If test.src is set, program runs in jtreg mode, and will throw an Error
+     * if any errors arise, otherwise System.exit will be used, unless the gui
+     * viewer is being used. In jtreg mode, the default base directory for file
+     * args is the value of ${test.src}. In jtreg mode, the -r option can be
+     * given to change the default base directory to the root test directory.
+     */
+    public static void main(String... args) {
+        String testSrc = System.getProperty("test.src");
+        File baseDir = (testSrc == null) ? null : new File(testSrc);
+        boolean ok = new CheckAttributedTree().run(baseDir, args);
+        if (!ok) {
+            if (testSrc != null)  // jtreg mode
+                throw new Error("failed");
+            else
+                System.exit(1);
+        }
+    }
+
+    /**
+     * Run the program. A base directory can be provided for file arguments.
+     * In jtreg mode, the -r option can be given to change the default base
+     * directory to the test root directory. For other options, see usage().
+     * @param baseDir base directory for any file arguments.
+     * @param args command line args
+     * @return true if successful or in gui mode
+     */
+    boolean run(File baseDir, String... args) {
+        if (args.length == 0) {
+            usage(System.out);
+            return true;
+        }
+
+        List<File> files = new ArrayList<File>();
+        for (int i = 0; i < args.length; i++) {
+            String arg = args[i];
+            if (arg.equals("-encoding") && i + 1 < args.length)
+                encoding = args[++i];
+            else if (arg.equals("-gui"))
+                gui = true;
+            else if (arg.equals("-q"))
+                quiet = true;
+            else if (arg.equals("-v"))
+                verbose = true;
+            else if (arg.equals("-t") && i + 1 < args.length)
+                tags.add(args[++i]);
+            else if (arg.equals("-ef") && i + 1 < args.length)
+                excludeFiles.add(new File(baseDir, args[++i]));
+            else if (arg.equals("-et") && i + 1 < args.length)
+                excludeTags.add(args[++i]);
+            else if (arg.equals("-r")) {
+                if (excludeFiles.size() > 0)
+                    throw new Error("-r must be used before -ef");
+                File d = baseDir;
+                while (!new File(d, "TEST.ROOT").exists()) {
+                    if (d == null)
+                        throw new Error("cannot find TEST.ROOT");
+                    d = d.getParentFile();
+                }
+                baseDir = d;
+            }
+            else if (arg.startsWith("-"))
+                throw new Error("unknown option: " + arg);
+            else {
+                while (i < args.length)
+                    files.add(new File(baseDir, args[i++]));
+            }
+        }
+
+        for (File file: files) {
+            if (file.exists())
+                test(file);
+            else
+                error("File not found: " + file);
+        }
+
+        if (fileCount != 1)
+            System.err.println(fileCount + " files read");
+        if (errors > 0)
+            System.err.println(errors + " errors");
+
+        return (gui || errors == 0);
+    }
+
+    /**
+     * Print command line help.
+     * @param out output stream
+     */
+    void usage(PrintStream out) {
+        out.println("Usage:");
+        out.println("  java CheckAttributedTree options... files...");
+        out.println("");
+        out.println("where options include:");
+        out.println("-q        Quiet: don't report on inapplicable files");
+        out.println("-gui      Display returns in a GUI viewer");
+        out.println("-v        Verbose: report on files as they are being read");
+        out.println("-t tag    Limit checks to tree nodes with this tag");
+        out.println("          Can be repeated if desired");
+        out.println("-ef file  Exclude file or directory");
+        out.println("-et tag   Exclude tree nodes with given tag name");
+        out.println("");
+        out.println("files may be directories or files");
+        out.println("directories will be scanned recursively");
+        out.println("non java files, or java files which cannot be parsed, will be ignored");
+        out.println("");
+    }
+
+    /**
+     * Test a file. If the file is a directory, it will be recursively scanned
+     * for java files.
+     * @param file the file or directory to test
+     */
+    void test(File file) {
+        if (excludeFiles.contains(file)) {
+            if (!quiet)
+                error("File " + file + " excluded");
+            return;
+        }
+
+        if (file.isDirectory()) {
+            for (File f: file.listFiles()) {
+                test(f);
+            }
+            return;
+        }
+
+        if (file.isFile() && file.getName().endsWith(".java")) {
+            try {
+                if (verbose)
+                    System.err.println(file);
+                fileCount++;
+                NPETester p = new NPETester();
+                p.test(read(file));
+            } catch (AttributionException e) {
+                if (!quiet) {
+                    error("Error attributing " + file + "\n" + e.getMessage());
+                }
+            } catch (IOException e) {
+                error("Error reading " + file + ": " + e);
+            }
+            return;
+        }
+
+        if (!quiet)
+            error("File " + file + " ignored");
+    }
+
+    /**
+     * Read a file.
+     * @param file the file to be read
+     * @return the tree for the content of the file
+     * @throws IOException if any IO errors occur
+     * @throws TreePosTest.ParseException if any errors occur while parsing the file
+     */
+    List<Pair<JCCompilationUnit, JCTree>> read(File file) throws IOException, AttributionException {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        Reporter r = new Reporter(pw);
+        JavacTool tool = JavacTool.create();
+        Charset cs = (encoding == null ? null : Charset.forName(encoding));
+        StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
+        String[] opts = { "-XDshouldStopPolicy=ATTR", "-XDverboseCompilePolicy" };
+        JavacTask task = tool.getTask(pw, fm, r, Arrays.asList(opts), null, files);
+        final List<Element> analyzedElems = new ArrayList<>();
+        task.setTaskListener(new TaskListener() {
+            public void started(TaskEvent e) {
+                if (e.getKind() == TaskEvent.Kind.ANALYZE)
+                        analyzedElems.add(e.getTypeElement());
+            }
+            public void finished(TaskEvent e) { }
+        });
+
+        try {
+            Iterable<? extends CompilationUnitTree> trees = task.parse();
+            task.analyze();
+            List<Pair<JCCompilationUnit, JCTree>> res = new ArrayList<>();
+            //System.out.println("Try to add pairs. Elems are " + analyzedElems);
+            for (CompilationUnitTree t : trees) {
+               JCCompilationUnit cu = (JCCompilationUnit)t;
+               for (JCTree def : cu.defs) {
+                   if (def.getTag() == JCTree.CLASSDEF &&
+                           analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) {
+                       //System.out.println("Adding pair...");
+                       res.add(new Pair<>(cu, def));
+                   }
+               }
+            }
+            return res;
+        }
+        catch (Throwable t) {
+            throw new AttributionException("Exception while attributing file: " + file);
+        }
+    }
+
+    /**
+     * Report an error. When the program is complete, the program will either
+     * exit or throw an Error if any errors have been reported.
+     * @param msg the error message
+     */
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    /** Number of files that have been analyzed. */
+    int fileCount;
+    /** Number of errors reported. */
+    int errors;
+    /** Flag: don't report irrelevant files. */
+    boolean quiet;
+    /** Flag: show errors in GUI viewer. */
+    boolean gui;
+    /** The GUI viewer for errors. */
+    Viewer viewer;
+    /** Flag: report files as they are processed. */
+    boolean verbose;
+    /** Option: encoding for test files. */
+    String encoding;
+    /** The set of tags for tree nodes to be analyzed; if empty, all tree nodes
+     * are analyzed. */
+    Set<String> tags = new HashSet<String>();
+    /** Set of files and directories to be excluded from analysis. */
+    Set<File> excludeFiles = new HashSet<File>();
+    /** Set of tag names to be excluded from analysis. */
+    Set<String> excludeTags = new HashSet<String>();
+    /** Utility class for trees */
+    TreeUtil treeUtil = new TreeUtil();
+
+    /**
+     * Main class for testing assertions concerning types/symbol
+     * left uninitialized after attribution
+     */
+    private class NPETester extends TreeScanner {
+        void test(List<Pair<JCCompilationUnit, JCTree>> trees) {
+            for (Pair<JCCompilationUnit, JCTree> p : trees) {
+                sourcefile = p.fst.sourcefile;
+                endPosTable = p.fst.endPositions;
+                encl = new Info(p.snd, endPosTable);
+                p.snd.accept(this);
+            }
+        }
+
+        @Override
+        public void scan(JCTree tree) {
+            if (tree == null ||
+                    excludeTags.contains(treeUtil.nameFromTag(tree.getTag()))) {
+                return;
+            }
+
+            Info self = new Info(tree, endPosTable);
+            check(!mandatoryType(tree) ||
+                    (tree.type != null &&
+                    checkFields(tree)),
+                    "'null' found in tree ",
+                    self);
+
+            Info prevEncl = encl;
+            encl = self;
+            tree.accept(this);
+            encl = prevEncl;
+        }
+
+        private boolean mandatoryType(JCTree that) {
+            return that instanceof JCTree.JCExpression ||
+                    that.getTag() == JCTree.VARDEF ||
+                    that.getTag() == JCTree.METHODDEF ||
+                    that.getTag() == JCTree.CLASSDEF;
+        }
+
+        private final List<String> excludedFields = Arrays.asList("varargsElement");
+
+        void check(boolean ok, String label, Info self) {
+            if (!ok) {
+                if (gui) {
+                    if (viewer == null)
+                        viewer = new Viewer();
+                    viewer.addEntry(sourcefile, label, encl, self);
+                }
+                error(label + self.toString() + " encl: " + encl.toString() + " in file: " + sourcefile + "  " + self.tree);
+            }
+        }
+
+        boolean checkFields(JCTree t) {
+            List<Field> fieldsToCheck = treeUtil.getFieldsOfType(t,
+                    excludedFields,
+                    Symbol.class,
+                    Type.class);
+            for (Field f : fieldsToCheck) {
+                try {
+                    if (f.get(t) == null) {
+                        return false;
+                    }
+                }
+                catch (IllegalAccessException e) {
+                    System.err.println("Cannot read field: " + f);
+                    //swallow it
+                }
+            }
+            return true;
+        }
+
+        @Override
+        public void visitImport(JCImport tree) { }
+
+        @Override
+        public void visitTopLevel(JCCompilationUnit tree) {
+            scan(tree.defs);
+        }
+
+        JavaFileObject sourcefile;
+        Map<JCTree, Integer> endPosTable;
+        Info encl;
+    }
+
+    /**
+     * Utility class providing easy access to position and other info for a tree node.
+     */
+    private class Info {
+        Info() {
+            tree = null;
+            tag = JCTree.ERRONEOUS;
+            start = 0;
+            pos = 0;
+            end = Integer.MAX_VALUE;
+        }
+
+        Info(JCTree tree, Map<JCTree, Integer> endPosTable) {
+            this.tree = tree;
+            tag = tree.getTag();
+            start = TreeInfo.getStartPos(tree);
+            pos = tree.pos;
+            end = TreeInfo.getEndPos(tree, endPosTable);
+        }
+
+        @Override
+        public String toString() {
+            return treeUtil.nameFromTag(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]";
+        }
+
+        final JCTree tree;
+        final int tag;
+        final int start;
+        final int pos;
+        final int end;
+    }
+
+    /**
+     * Names for tree tags.
+     * javac does not provide an API to convert tag values to strings, so this class uses
+     * reflection to determine names of public static final int values in JCTree.
+     */
+    private static class TreeUtil {
+        String nameFromTag(int tag) {
+            if (names == null) {
+                names = new HashMap<Integer, String>();
+                Class c = JCTree.class;
+                for (Field f : c.getDeclaredFields()) {
+                    if (f.getType().equals(int.class)) {
+                        int mods = f.getModifiers();
+                        if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) {
+                            try {
+                                names.put(f.getInt(null), f.getName());
+                            } catch (IllegalAccessException e) {
+                            }
+                        }
+                    }
+                }
+            }
+            String name = names.get(tag);
+            return (name == null) ? "??" : name;
+        }
+
+        List<Field> getFieldsOfType(JCTree t, List<String> excludeNames, Class<?>... types) {
+            List<Field> buf = new ArrayList<Field>();
+            for (Field f : t.getClass().getDeclaredFields()) {
+                if (!excludeNames.contains(f.getName())) {
+                    for (Class<?> type : types) {
+                        if (type.isAssignableFrom(f.getType())) {
+                            f.setAccessible(true);
+                            buf.add(f);
+                            break;
+                        }
+                    }
+                }
+            }
+            return buf;
+        }
+
+        private Map<Integer, String> names;
+    }
+
+    /**
+     * Thrown when errors are found parsing a java file.
+     */
+    private static class ParseException extends Exception {
+        ParseException(String msg) {
+            super(msg);
+        }
+    }
+
+    private static class AttributionException extends Exception {
+        AttributionException(String msg) {
+            super(msg);
+        }
+    }
+
+    /**
+     * DiagnosticListener to report diagnostics and count any errors that occur.
+     */
+    private static class Reporter implements DiagnosticListener<JavaFileObject> {
+        Reporter(PrintWriter out) {
+            this.out = out;
+        }
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            out.println(diagnostic);
+            switch (diagnostic.getKind()) {
+                case ERROR:
+                    errors++;
+            }
+        }
+        int errors;
+        PrintWriter out;
+    }
+
+    /**
+     * GUI viewer for issues found by TreePosTester. The viewer provides a drop
+     * down list for selecting error conditions, a header area providing details
+     * about an error, and a text area with the ranges of text highlighted as
+     * appropriate.
+     */
+    private class Viewer extends JFrame {
+        /**
+         * Create a viewer.
+         */
+        Viewer() {
+            initGUI();
+        }
+
+        /**
+         * Add another entry to the list of errors.
+         * @param file The file containing the error
+         * @param check The condition that was being tested, and which failed
+         * @param encl the enclosing tree node
+         * @param self the tree node containing the error
+         */
+        void addEntry(JavaFileObject file, String check, Info encl, Info self) {
+            Entry e = new Entry(file, check, encl, self);
+            DefaultComboBoxModel m = (DefaultComboBoxModel) entries.getModel();
+            m.addElement(e);
+            if (m.getSize() == 1)
+                entries.setSelectedItem(e);
+        }
+
+        /**
+         * Initialize the GUI window.
+         */
+        private void initGUI() {
+            JPanel head = new JPanel(new GridBagLayout());
+            GridBagConstraints lc = new GridBagConstraints();
+            GridBagConstraints fc = new GridBagConstraints();
+            fc.anchor = GridBagConstraints.WEST;
+            fc.fill = GridBagConstraints.HORIZONTAL;
+            fc.gridwidth = GridBagConstraints.REMAINDER;
+
+            entries = new JComboBox();
+            entries.addActionListener(new ActionListener() {
+                public void actionPerformed(ActionEvent e) {
+                    showEntry((Entry) entries.getSelectedItem());
+                }
+            });
+            fc.insets.bottom = 10;
+            head.add(entries, fc);
+            fc.insets.bottom = 0;
+            head.add(new JLabel("check:"), lc);
+            head.add(checkField = createTextField(80), fc);
+            fc.fill = GridBagConstraints.NONE;
+            head.add(setBackground(new JLabel("encl:"), enclColor), lc);
+            head.add(enclPanel = new InfoPanel(), fc);
+            head.add(setBackground(new JLabel("self:"), selfColor), lc);
+            head.add(selfPanel = new InfoPanel(), fc);
+            add(head, BorderLayout.NORTH);
+
+            body = new JTextArea();
+            body.setFont(Font.decode(Font.MONOSPACED));
+            body.addCaretListener(new CaretListener() {
+                public void caretUpdate(CaretEvent e) {
+                    int dot = e.getDot();
+                    int mark = e.getMark();
+                    if (dot == mark)
+                        statusText.setText("dot: " + dot);
+                    else
+                        statusText.setText("dot: " + dot + ", mark:" + mark);
+                }
+            });
+            JScrollPane p = new JScrollPane(body,
+                    JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
+                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
+            p.setPreferredSize(new Dimension(640, 480));
+            add(p, BorderLayout.CENTER);
+
+            statusText = createTextField(80);
+            add(statusText, BorderLayout.SOUTH);
+
+            pack();
+            setLocationRelativeTo(null); // centered on screen
+            setVisible(true);
+            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+        }
+
+        /** Show an entry that has been selected. */
+        private void showEntry(Entry e) {
+            try {
+                // update simple fields
+                setTitle(e.file.getName());
+                checkField.setText(e.check);
+                enclPanel.setInfo(e.encl);
+                selfPanel.setInfo(e.self);
+                // show file text with highlights
+                body.setText(e.file.getCharContent(true).toString());
+                Highlighter highlighter = body.getHighlighter();
+                highlighter.removeAllHighlights();
+                addHighlight(highlighter, e.encl, enclColor);
+                addHighlight(highlighter, e.self, selfColor);
+                scroll(body, getMinPos(enclPanel.info, selfPanel.info));
+            } catch (IOException ex) {
+                body.setText("Cannot read " + e.file.getName() + ": " + e);
+            }
+        }
+
+        /** Create a test field. */
+        private JTextField createTextField(int width) {
+            JTextField f = new JTextField(width);
+            f.setEditable(false);
+            f.setBorder(null);
+            return f;
+        }
+
+        /** Add a highlighted region based on the positions in an Info object. */
+        private void addHighlight(Highlighter h, Info info, Color c) {
+            int start = info.start;
+            int end = info.end;
+            if (start == -1 && end == -1)
+                return;
+            if (start == -1)
+                start = end;
+            if (end == -1)
+                end = start;
+            try {
+                h.addHighlight(info.start, info.end,
+                        new DefaultHighlighter.DefaultHighlightPainter(c));
+                if (info.pos != -1) {
+                    Color c2 = new Color(c.getRed(), c.getGreen(), c.getBlue(), (int)(.4f * 255)); // 40%
+                    h.addHighlight(info.pos, info.pos + 1,
+                        new DefaultHighlighter.DefaultHighlightPainter(c2));
+                }
+            } catch (BadLocationException e) {
+                e.printStackTrace();
+            }
+        }
+
+        /** Get the minimum valid position in a set of info objects. */
+        private int getMinPos(Info... values) {
+            int i = Integer.MAX_VALUE;
+            for (Info info: values) {
+                if (info.start >= 0) i = Math.min(i, info.start);
+                if (info.pos   >= 0) i = Math.min(i, info.pos);
+                if (info.end   >= 0) i = Math.min(i, info.end);
+            }
+            return (i == Integer.MAX_VALUE) ? 0 : i;
+        }
+
+        /** Set the background on a component. */
+        private JComponent setBackground(JComponent comp, Color c) {
+            comp.setOpaque(true);
+            comp.setBackground(c);
+            return comp;
+        }
+
+        /** Scroll a text area to display a given position near the middle of the visible area. */
+        private void scroll(final JTextArea t, final int pos) {
+            // Using invokeLater appears to give text a chance to sort itself out
+            // before the scroll happens; otherwise scrollRectToVisible doesn't work.
+            // Maybe there's a better way to sync with the text...
+            EventQueue.invokeLater(new Runnable() {
+                public void run() {
+                    try {
+                        Rectangle r = t.modelToView(pos);
+                        JScrollPane p = (JScrollPane) SwingUtilities.getAncestorOfClass(JScrollPane.class, t);
+                        r.y = Math.max(0, r.y - p.getHeight() * 2 / 5);
+                        r.height += p.getHeight() * 4 / 5;
+                        t.scrollRectToVisible(r);
+                    } catch (BadLocationException ignore) {
+                    }
+                }
+            });
+        }
+
+        private JComboBox entries;
+        private JTextField checkField;
+        private InfoPanel enclPanel;
+        private InfoPanel selfPanel;
+        private JTextArea body;
+        private JTextField statusText;
+
+        private Color selfColor = new Color(0.f, 1.f, 0.f, 0.2f); // 20% green
+        private Color enclColor = new Color(1.f, 0.f, 0.f, 0.2f); // 20% red
+
+        /** Panel to display an Info object. */
+        private class InfoPanel extends JPanel {
+            InfoPanel() {
+                add(tagName = createTextField(20));
+                add(new JLabel("start:"));
+                add(addListener(start = createTextField(6)));
+                add(new JLabel("pos:"));
+                add(addListener(pos = createTextField(6)));
+                add(new JLabel("end:"));
+                add(addListener(end = createTextField(6)));
+            }
+
+            void setInfo(Info info) {
+                this.info = info;
+                tagName.setText(treeUtil.nameFromTag(info.tag));
+                start.setText(String.valueOf(info.start));
+                pos.setText(String.valueOf(info.pos));
+                end.setText(String.valueOf(info.end));
+            }
+
+            JTextField addListener(final JTextField f) {
+                f.addMouseListener(new MouseAdapter() {
+                    @Override
+                    public void mouseClicked(MouseEvent e) {
+                        body.setCaretPosition(Integer.valueOf(f.getText()));
+                        body.getCaret().setVisible(true);
+                    }
+                });
+                return f;
+            }
+
+            Info info;
+            JTextField tagName;
+            JTextField start;
+            JTextField pos;
+            JTextField end;
+        }
+
+        /** Object to record information about an error to be displayed. */
+        private class Entry {
+            Entry(JavaFileObject file, String check, Info encl, Info self) {
+                this.file = file;
+                this.check = check;
+                this.encl = encl;
+                this.self= self;
+            }
+
+            @Override
+            public String toString() {
+                return file.getName() + " " + check + " " + getMinPos(encl, self);
+            }
+
+            final JavaFileObject file;
+            final String check;
+            final Info encl;
+            final Info self;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver01.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,10 @@
+/*
+  * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver01.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver01.java
+ */
+
+class Test { { x = "" } }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver01.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,3 @@
+FailOver01.java:10:22: compiler.err.expected: ';'
+FailOver01.java:10:16: compiler.err.cant.resolve.location: kindname.variable, x, , , kindname.class, Test
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver02.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver02.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver02.java
+ */
+
+class Test implements AutoCloseable {
+    void test() {
+        try(Test t = null) {}
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver02.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,3 @@
+FailOver02.java:10:1: compiler.err.does.not.override.abstract: Test, close(), java.lang.AutoCloseable
+FailOver02.java:12:9: compiler.err.cant.resolve.location.args: kindname.method, close, , , kindname.class, Test
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver03.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver03.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver03.java
+ */
+
+class Test extends Test {
+   Test i;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver03.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver03.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver04.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver04.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver04.java
+ */
+
+class Test {
+   { new Unknown() {}; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver04.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver04.java:11:10: compiler.err.cant.resolve.location: kindname.class, Unknown, , , kindname.class, Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver05.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver05.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver05.java
+ */
+
+class Test extends Test {
+   { for ( Integer x : null) {} }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver05.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver05.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver06.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver06.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver06.java
+ */
+
+class Test extends Test {
+    Inference x = 1;
+    { if (x == 1) { } else { } }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver06.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver06.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver07.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver07.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver07.java
+ */
+
+class Test extends Test {
+    Integer x = 1;
+    { do {} while (x); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver07.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver07.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver08.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver08.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver08.java
+ */
+
+class Test extends Test {
+    Integer x = 1;
+    { while (x) {}; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver08.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver08.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver09.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,13 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver09.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver09.java
+ */
+
+class Test extends Test {
+    Integer x = 1;
+    { for (x = 0 ; x ; x++) {}; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver09.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver09.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver10.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver10.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver10.java
+ */
+
+class Test extends Test {
+
+    boolean cond;
+
+    { Object o = null; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver10.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver10.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver11.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver11.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver11.java
+ */
+
+class Test extends Test {
+
+    boolean cond;
+
+    void m(Object o) {}
+
+    { m(cond ? null : null); }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver11.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver11.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver12.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver12.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver12.java
+ */
+
+class Test extends Test {
+
+    Integer x = 1;
+
+    { try {} catch (Exception e) {} }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver12.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver12.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver13.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver13.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver13.java
+ */
+
+class Test extends Test {
+
+    Integer x = 1;
+
+    { x = (Object)o; }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver13.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver13.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver14.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584
+ * @summary Flow.java should be more error-friendly
+ * @author mcimadamore
+ *
+ * @compile/fail/ref=FailOver14.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver14.java
+ */
+
+class Test extends Test  {
+
+   { for (Integer x : !x) { } }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver14.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,2 @@
+FailOver14.java:10:1: compiler.err.cyclic.inheritance: Test
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/OverrideBridge.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,163 @@
+/*
+ * 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 6337171
+ * @summary  javac should create bridge methods when type variable bounds restricted
+ * @run main OverrideBridge
+ */
+
+import java.io.*;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Descriptor.InvalidDescriptor;
+import com.sun.tools.classfile.Method;
+
+public class OverrideBridge {
+
+    enum Implementation {
+        IMPLICIT(""),
+        EXPLICIT("@Override public abstract X m(X x);");
+
+        String impl;
+
+        Implementation(String impl) {
+            this.impl = impl;
+        }
+    }
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        final static String sourceStub =
+                        "abstract class A<X> {\n" +
+                        "   public abstract X m(X x);\n" +
+                        "}\n" +
+                        "interface I<X> {\n" +
+                        "X m(X x);\n" +
+                        "}\n" +
+                        "abstract class B<X extends B<X>> extends A<X> implements I<X> { #B }\n" +
+                        "abstract class C<X extends C<X>> extends B<X>  { #C }\n" +
+                        "abstract class D<X extends D<X>> extends C<X>  { #D }\n";
+
+        String source;
+
+        public JavaSource(Implementation implB, Implementation implC, Implementation implD) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = sourceStub.replace("#B", implB.impl).replace("#C", implC.impl).replace("#D", implD.impl);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        Map<ClassFile, List<Method>> refMembers =
+                compile(Implementation.EXPLICIT, Implementation.EXPLICIT, Implementation.EXPLICIT, "ref");
+        int i = 0;
+        for (Implementation implB : Implementation.values()) {
+            for (Implementation implC : Implementation.values()) {
+                for (Implementation implD : Implementation.values()) {
+                    Map<ClassFile, List<Method>> membersToCheck = compile(implB, implC, implD, "out_" + i++);
+                    check(refMembers, membersToCheck);
+                }
+            }
+        }
+    }
+
+    static String workDir = System.getProperty("user.dir");
+
+    static Map<ClassFile, List<Method>> compile(Implementation implB, Implementation implC, Implementation implD, String destPath) throws Exception {
+        File destDir = new File(workDir, destPath); destDir.mkdir();
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavaSource source = new JavaSource(implB, implC, implD);
+        JavacTask ct = (JavacTask)tool.getTask(null, null, null,
+                Arrays.asList("-d", destPath), null, Arrays.asList(source));
+        ct.generate();
+        Map<ClassFile, List<Method>> members = new HashMap<>();
+        addMembers(destDir, members);
+        return members;
+    }
+
+    static void addMembers(File destDir, Map<ClassFile, List<Method>> members) {
+        String[] names = { "B.class", "C.class", "D.class" };
+        try {
+            for (String name : names) {
+                File f = new File(destDir, name);
+                ClassFile cf = ClassFile.read(f);
+                members.put(cf, readMethod(cf, "m"));
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading classes");
+        }
+    }
+
+    static List<Method> readMethod(ClassFile cf, String name) throws ConstantPoolException {
+        List<Method> buf = new ArrayList<>();
+        for (Method m : cf.methods) {
+            if (m.getName(cf.constant_pool).equals(name)) {
+                buf.add(m);
+            }
+        }
+        return buf;
+    }
+
+    static void check(Map<ClassFile, List<Method>> refMembers, Map<ClassFile, List<Method>> membersToCheck) throws ConstantPoolException, InvalidDescriptor {
+        for (Map.Entry<ClassFile, List<Method>> ref : refMembers.entrySet()) {
+            ClassFile cRef = ref.getKey();
+            for (Method mRef : ref.getValue()) {
+                boolean ok = false;
+                for (Map.Entry<ClassFile, List<Method>> toCheck : membersToCheck.entrySet()) {
+                    ClassFile cToCheck = toCheck.getKey();
+                    for (Method mToCheck : toCheck.getValue()) {
+                        if (cRef.getName().equals(cToCheck.getName()) &&
+                                mRef.descriptor.getReturnType(cRef.constant_pool).equals(
+                                mToCheck.descriptor.getReturnType(cToCheck.constant_pool)) &&
+                                mRef.descriptor.getParameterTypes(cRef.constant_pool).equals(
+                                mToCheck.descriptor.getParameterTypes(cToCheck.constant_pool))) {
+                            ok = true;
+                        }
+                    }
+                }
+                if (!ok) {
+                    throw new AssertionError("Matching method descriptor for " + mRef.descriptor.getParameterTypes(cRef.constant_pool) + "not found");
+                }
+            }
+        }
+    }
+}
--- a/test/tools/javac/generics/diamond/neg/Neg06.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg06.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,4 +1,4 @@
-Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>)
-Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
-Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
+Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>)
+Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
+Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
 3 errors
--- a/test/tools/javac/generics/inference/6315770/T6315770.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6315770/T6315770.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,3 +1,3 @@
 T6315770.java:16:42: compiler.err.undetermined.type.1: <T>T6315770<T>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)
-T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)), <T>T6315770<T>, T6315770<? super java.lang.String>
+T6315770.java:17:40: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)), <T>T6315770<T>, T6315770<? super java.lang.String>
 2 errors
--- a/test/tools/javac/generics/inference/6611449/T6611449.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6611449/T6611449.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
-T6611449.java:18:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int, kindname.class, T6611449<S>
-T6611449.java:19:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6611449, , int,int, kindname.class, T6611449<S>
-T6611449.java:20:9: compiler.err.cant.apply.symbol: kindname.method, m1, T, int, kindname.class, T6611449<S>, null
-T6611449.java:21:9: compiler.err.cant.apply.symbol: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, null
+T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S))}
+T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch))}
+T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)
+T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)
 4 errors
--- a/test/tools/javac/generics/inference/6638712/T6638712a.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712a.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,2 +1,2 @@
-T6638712a.java:16:41: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.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>
+T6638712a.java:16: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>
 1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712b.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712b.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,2 +1,2 @@
-T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: T, T, java.lang.String)), <T>T, java.lang.String
+T6638712b.java:14:21: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: T, T, java.lang.String)), <T>T, java.lang.String
 1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712c.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712c.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,2 +1,2 @@
-T6638712c.java:16:9: compiler.err.cant.apply.symbol: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, null
+T6638712c.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Enum[],java.util.Comparator<? super java.lang.Enum>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>)
 1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712d.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712d.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,2 +1,2 @@
-T6638712d.java:16:9: compiler.err.cant.apply.symbol: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, null
+T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.params: java.lang.String,java.util.List<java.util.List<java.lang.String>>, int,java.util.List<java.util.List<java.lang.String>>)
 1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712e.out	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712e.out	Wed Nov 10 19:07:04 2010 +0000
@@ -1,2 +1,2 @@
-T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.no.conforming.instance.exists: X, T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>)), <X>T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>
+T6638712e.java:17:27: compiler.err.prob.found.req: (compiler.misc.incompatible.types.1: (compiler.misc.infer.no.conforming.instance.exists: X, T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>)), <X>T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>
 1 error
--- a/test/tools/javac/generics/inference/6938454/T6938454a.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6938454/T6938454a.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Sun Microsystems, Inc.  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
@@ -16,9 +16,9 @@
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
  */
 
 /*
--- a/test/tools/javac/generics/inference/6938454/T6938454b.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/generics/inference/6938454/T6938454b.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Sun Microsystems, Inc.  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
@@ -16,9 +16,9 @@
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
  */
 
 import java.util.List;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lib/JavacTestingAbstractProcessor.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,100 @@
+/*
+ * 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.*;
+import javax.annotation.processing.*;
+import javax.lang.model.SourceVersion;
+import static javax.lang.model.SourceVersion.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+
+/**
+ * An abstract annotation processor tailored to javac regression testing.
+ */
+public abstract class JavacTestingAbstractProcessor extends AbstractProcessor {
+    private static final Set<String> allAnnotations;
+
+    static {
+        Set<String> tmp = new HashSet<>();
+        tmp.add("*");
+        allAnnotations = Collections.unmodifiableSet(tmp);
+    }
+
+    protected Elements eltUtils;
+    protected Elements elements;
+    protected Types    typeUtils;
+    protected Types    types;
+    protected Filer    filer;
+    protected Messager messager;
+    protected Map<String, String> options;
+
+    /**
+     * Constructor for subclasses to call.
+     */
+    protected JavacTestingAbstractProcessor() {
+        super();
+    }
+
+    /**
+     * Return the latest source version. Unless this method is
+     * overridden, an {@code IllegalStateException} will be thrown if a
+     * subclass has a {@code SupportedSourceVersion} annotation.
+     */
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        SupportedSourceVersion ssv = this.getClass().getAnnotation(SupportedSourceVersion.class);
+        if (ssv != null)
+            throw new IllegalStateException("SupportedSourceVersion annotation not supported here.");
+
+        return SourceVersion.latest();
+    }
+
+    /**
+     * If the processor class is annotated with {@link
+     * SupportedAnnotationTypes}, return an unmodifiable set with the
+     * same set of strings as the annotation.  If the class is not so
+     * annotated, a one-element set containing {@code "*"} is returned
+     * to indicate all annotations are processed.
+     *
+     * @return the names of the annotation types supported by this
+     * processor, or an empty set if none
+     */
+    @Override
+    public Set<String> getSupportedAnnotationTypes() {
+        SupportedAnnotationTypes sat = this.getClass().getAnnotation(SupportedAnnotationTypes.class);
+        if (sat != null)
+            return super.getSupportedAnnotationTypes();
+        else
+            return allAnnotations;
+    }
+
+    @Override
+    public void init(ProcessingEnvironment processingEnv) {
+        super.init(processingEnv);
+        elements = eltUtils  = processingEnv.getElementUtils();
+        types = typeUtils = processingEnv.getTypeUtils();
+        filer     = processingEnv.getFiler();
+        messager  = processingEnv.getMessager();
+        options   = processingEnv.getOptions();
+    }
+}
--- a/test/tools/javac/meth/InvokeDyn.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/meth/InvokeDyn.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,12 +23,12 @@
 
 /*
  * @test
- * @bug 6754038
+ * @bug 6754038 6979327
  * @summary Generate call sites for method handle
  * @author jrose
  *
  * @library ..
- * @compile -source 7 -target 7 InvokeDyn.java
+ * @compile -source 7 -target 7 -XDinvokedynamic -XDallowTransitionalJSR292=no InvokeDyn.java
  */
 //No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
 
@@ -44,16 +44,21 @@
 
 package meth;
 
-import java.dyn.InvokeDynamic;
+import java.dyn.*;
 
 public class InvokeDyn {
+    class CS extends CallSite {
+        CS(Object x, Object y, Object z) { throw new RuntimeException(); }
+    }
+    //@BootstrapMethod(CS.class)  //note: requires 6964498
     void test() throws Throwable {
         Object x = "hello";
-        InvokeDynamic.greet(x, "world", 123);
-        InvokeDynamic.greet(x, "mundus", 456);
-        InvokeDynamic.greet(x, "kosmos", 789);
-        InvokeDynamic.<String>cogitate(10.11121, 3.14);
-        InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
-        InvokeDynamic.<int>invoke("goodbye");
+        Object ojunk; int ijunk;
+        ojunk = InvokeDynamic.greet(x, "world", 123);
+        ojunk = InvokeDynamic.greet(x, "mundus", 456);
+        ojunk = InvokeDynamic.greet(x, "kosmos", 789);
+        ojunk = (String) InvokeDynamic.cogitate(10.11121, 3.14);
+        InvokeDynamic.#"yow: what I mean to say is, please treat this one specially"(null);
+        ijunk = (int) InvokeDynamic.invoke("goodbye");
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/meth/InvokeDynTrans.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2008-2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6754038 6979327
+ * @summary Generate call sites for method handle
+ * @author jrose
+ *
+ * @library ..
+ * @compile/fail/ref=InvokeDynTrans.out -Werror -XDrawDiagnostics -source 7 -target 7 InvokeDynTrans.java
+ */
+//No: @run main/othervm -XX:+EnableInvokeDynamic meth.InvokeDyn
+
+/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
+ * $ (cd make; make)
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeDyn.java
+ * $ javap -c -classpath dist meth.InvokeDyn
+ * </code>
+ */
+
+package meth;
+
+import java.dyn.InvokeDynamic;
+
+public class InvokeDynTrans {
+    void test() throws Throwable {
+        Object x = "hello";
+        InvokeDynamic.greet(x, "world", 123);
+        InvokeDynamic.greet(x, "mundus", 456);
+        InvokeDynamic.greet(x, "kosmos", 789);
+        InvokeDynamic.<String>cogitate(10.11121, 3.14);
+        InvokeDynamic.<void>#"yow: what I mean to say is, please treat this one specially"(null);
+        InvokeDynamic.<int>invoke("goodbye");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/meth/InvokeDynTrans.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,6 @@
+InvokeDynTrans.java:55:39: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeDynTrans.java:56:91: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeDynTrans.java:57:34: compiler.warn.type.parameter.on.polymorphic.signature
+- compiler.err.warnings.and.werror
+1 error
+3 warnings
--- a/test/tools/javac/meth/InvokeMH.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/meth/InvokeMH.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,11 +23,11 @@
 
 /*
  * @test
- * @bug 6754038
+ * @bug 6754038 6979327
  * @summary Generate call sites for method handle
  * @author jrose
  *
- * @compile -source 7 -target 7 InvokeMH.java
+ * @compile -source 7 -target 7 -XDallowTransitionalJSR292=no InvokeMH.java
  */
 
 /*
@@ -57,20 +57,17 @@
         Object k = "kosmos";
         mh_SiO.invokeExact((String)k, 789);
         o = mh_SiO.invokeExact((String)null, 000);
-        o = mh_SiO.<Object>invokeExact("arda", -123);
+        o = (Object) mh_SiO.invokeExact("arda", -123);
 
         // sig = ()String
-        s = mh_vS.<String>invokeExact();
+        s = (String) mh_vS.invokeExact();
 
         // sig = ()int
-        i = mh_vi.<int>invokeExact();
-        o = mh_vi.<int>invokeExact();
-        //s = mh_vi.<int>invokeExact(); //BAD
-        mh_vi.<int>invokeExact();
+        i = (int) mh_vi.invokeExact();
+        o = (int) mh_vi.invokeExact();
 
         // sig = ()void
-        //o = mh_vv.<void>invokeExact(); //BAD
-        mh_vv.<void>invokeExact();
+        mh_vv.invokeExact();
     }
 
     void testGen(MethodHandle mh_SiO,
@@ -80,24 +77,23 @@
         Object o; String s; int i;  // for return type testing
 
         // next five must have sig = (*,*)*
-        mh_SiO.invokeGeneric((Object)"world", (Object)123);
-        mh_SiO.<void>invokeGeneric((Object)"mundus", (Object)456);
+        o = mh_SiO.invokeGeneric((Object)"world", (Object)123);
+        mh_SiO.invokeGeneric((Object)"mundus", (Object)456);
         Object k = "kosmos";
-        mh_SiO.invokeGeneric(k, 789);
+        o = mh_SiO.invokeGeneric(k, 789);
         o = mh_SiO.invokeGeneric(null, 000);
-        o = mh_SiO.<Object>invokeGeneric("arda", -123);
+        o = mh_SiO.invokeGeneric("arda", -123);
 
         // sig = ()String
         o = mh_vS.invokeGeneric();
 
         // sig = ()int
-        i = mh_vi.<int>invokeGeneric();
-        o = mh_vi.invokeGeneric();
-        //s = mh_vi.<int>invokeGeneric(); //BAD
-        mh_vi.<void>invokeGeneric();
+        i = (int) mh_vi.invokeGeneric();
+        o = (int) mh_vi.invokeGeneric();
+        mh_vi.invokeGeneric();
 
         // sig = ()void
-        //o = mh_vv.<void>invokeGeneric(); //BAD
+        mh_vv.invokeGeneric();
         o = mh_vv.invokeGeneric();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/meth/InvokeMHTrans.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,102 @@
+/* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6754038 6979327
+ * @summary Generate call sites for method handle
+ * @author jrose
+ *
+ * @compile/fail/ref=InvokeMHTrans.out -Werror -XDrawDiagnostics -source 7 -target 7 InvokeMHTrans.java
+ */
+
+/*
+ * Standalone testing:
+ * <code>
+ * $ cd $MY_REPO_DIR/langtools
+ * $ (cd make; make)
+ * $ ./dist/bootstrap/bin/javac -d dist test/tools/javac/meth/InvokeMH.java
+ * $ javap -c -classpath dist meth.InvokeMH
+ * </code>
+ */
+
+package meth;
+
+import java.dyn.MethodHandle;
+
+public class InvokeMHTrans {
+    void test(MethodHandle mh_SiO,
+              MethodHandle mh_vS,
+              MethodHandle mh_vi,
+              MethodHandle mh_vv) throws Throwable {
+        Object o; String s; int i;  // for return type testing
+
+        // next five must have sig = (String,int)Object
+        mh_SiO.invokeExact("world", 123);
+        mh_SiO.invokeExact("mundus", 456);
+        Object k = "kosmos";
+        mh_SiO.invokeExact((String)k, 789);
+        o = mh_SiO.invokeExact((String)null, 000);
+        o = mh_SiO.<Object>invokeExact("arda", -123);
+
+        // sig = ()String
+        s = mh_vS.<String>invokeExact();
+
+        // sig = ()int
+        i = mh_vi.<int>invokeExact();
+        o = mh_vi.<int>invokeExact();
+        //s = mh_vi.<int>invokeExact(); //BAD
+        mh_vi.<int>invokeExact();
+
+        // sig = ()void
+        //o = mh_vv.<void>invokeExact(); //BAD
+        mh_vv.<void>invokeExact();
+    }
+
+    void testGen(MethodHandle mh_SiO,
+                 MethodHandle mh_vS,
+                 MethodHandle mh_vi,
+                 MethodHandle mh_vv) throws Throwable {
+        Object o; String s; int i;  // for return type testing
+
+        // next five must have sig = (*,*)*
+        mh_SiO.invokeGeneric((Object)"world", (Object)123);
+        mh_SiO.<void>invokeGeneric((Object)"mundus", (Object)456);
+        Object k = "kosmos";
+        mh_SiO.invokeGeneric(k, 789);
+        o = mh_SiO.invokeGeneric(null, 000);
+        o = mh_SiO.<Object>invokeGeneric("arda", -123);
+
+        // sig = ()String
+        o = mh_vS.invokeGeneric();
+
+        // sig = ()int
+        i = mh_vi.<int>invokeGeneric();
+        o = mh_vi.invokeGeneric();
+        //s = mh_vi.<int>invokeGeneric(); //BAD
+        mh_vi.<void>invokeGeneric();
+
+        // sig = ()void
+        //o = mh_vv.<void>invokeGeneric(); //BAD
+        o = mh_vv.invokeGeneric();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/meth/InvokeMHTrans.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,13 @@
+InvokeMHTrans.java:59:39: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:62:38: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:65:35: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:66:35: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:68:31: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:72:32: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:83:35: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:87:41: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:93:37: compiler.warn.type.parameter.on.polymorphic.signature
+InvokeMHTrans.java:96:34: compiler.warn.type.parameter.on.polymorphic.signature
+- compiler.err.warnings.and.werror
+1 error
+10 warnings
--- a/test/tools/javac/meth/MakeNegTests.sh	Tue Sep 14 11:37:19 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 6754038
-# @summary Verify correct rejection of strongly typed return values
-# @run shell MakeNegTests.sh
-
-default_template=InvokeMH.java
-javacflags='-source 7 -target 7'
-# the rest of this file is a generic "//BAD"-line tester
-
-: ${TESTSRC=.} ${TESTCLASSES=.}
-javac="${TESTJAVA+${TESTJAVA}/bin/}javac"
-
-verbose=false quiet=false
-
-main() {
-  case "${@-}" in
-  *.java*)
-    for template in "$@"; do
-      expand_and_test "$template"
-    done;;
-  *) expand_and_test "${TESTSRC}/$default_template";;
-  esac
-}
-
-expand_and_test() {
-  template=$1
-  expand "$@"
-  testneg "$@"
-}
-
-expand() {
-  template=$1
-  badlines=` grep -n < "$template" '//BAD' `
-  badcount=` echo "$badlines" | wc -l `
-  [ $badcount -gt 0 ] || { echo "No negative test cases in $template"; exit 1; }
-  $quiet || echo "Expanding $badcount negative test cases from $template:"
-  $quiet || echo "$badlines"
-  badnums=` echo "$badlines" | sed 's/:.*//' `
-  casestem=` getcasestem "$template" `
-  tclassname=` basename "$template" .java `
-  rm -f "$casestem"*.java
-  for badnum in $badnums; do
-    casefile="$casestem"${badnum}.java
-    cclassname=` basename "$casefile" .java `
-    sed < "$template" > "$casefile" "
-      s|@compile|@compile/fail|
-      / @[a-z]/s|@|##|
-      ${badnum}s:^ *[/*]*:    :
-      s/${tclassname}/${cclassname}/g
-    "
-    $verbose && diff -u "$template" "$casefile"
-  done
-}
-
-getcasestem() {
-  echo `basename $1` | sed 's/\.java$//;s/_BAD[0-9]*$//;s/$/_BAD/'
-}
-
-testneg() {
-  template=$1
-  for casefile in ` getcasestem "$template" `*.java; do
-    $quiet || echo -------- $javac $javacflags "$casefile"
-    $javac $javacflags "$casefile" > "$casefile".errlog 2>&1 && {
-      echo "*** Compilation unexpectedly succeeded:  $casefile"
-      exit 1
-    }
-    $quiet || echo "Compilation failed as expected"
-    $quiet || head ` $verbose || echo -3 ` < "$casefile".errlog
-    rm "$casefile".errlog
-  done
-}
-
-main "$@"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/meth/TestCP.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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 6991980
+ * @summary  polymorphic signature calls don't share the same CP entries
+ * @run main TestCP
+ */
+
+import com.sun.tools.classfile.Instruction;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.ConstantPool.*;
+import com.sun.tools.classfile.Method;
+
+import java.dyn.*;
+import java.io.*;
+
+public class TestCP {
+
+    static class TestClass {
+        void test(MethodHandle mh) throws Throwable {
+            Number n = mh.<Number>invokeExact("daddy",1,'n');
+            n = (Number)mh.invokeExact("bunny",1,'d');
+        }
+    }
+
+    static final String PS_TYPE = "(Ljava/lang/String;IC)Ljava/lang/Number;";
+    static final int PS_CALLS_COUNT = 2;
+    static final String SUBTEST_NAME = TestClass.class.getName() + ".class";
+    static final String TEST_METHOD_NAME = "test";
+
+    public static void main(String... args) throws Exception {
+        new TestCP().run();
+    }
+
+    public void run() throws Exception {
+        String workDir = System.getProperty("test.classes");
+        File compiledTest = new File(workDir, SUBTEST_NAME);
+        verifyMethodHandleInvocationDescriptors(compiledTest);
+    }
+
+    void verifyMethodHandleInvocationDescriptors(File f) {
+        System.err.println("verify: " + f);
+        try {
+            int count = 0;
+            ClassFile cf = ClassFile.read(f);
+            Method testMethod = null;
+            for (Method m : cf.methods) {
+                if (m.getName(cf.constant_pool).equals(TEST_METHOD_NAME)) {
+                    testMethod = m;
+                    break;
+                }
+            }
+            if (testMethod == null) {
+                throw new Error("Test method not found");
+            }
+            Code_attribute ea = (Code_attribute)testMethod.attributes.get(Attribute.Code);
+            if (testMethod == null) {
+                throw new Error("Code attribute for test() method not found");
+            }
+            int instr_count = 0;
+            int cp_entry = -1;
+
+            for (Instruction i : ea.getInstructions()) {
+                if (i.getMnemonic().equals("invokevirtual")) {
+                    instr_count++;
+                    if (cp_entry == -1) {
+                        cp_entry = i.getUnsignedShort(1);
+                    } else if (cp_entry != i.getUnsignedShort(1)) {
+                        throw new Error("Unexpected CP entry in polymorphic signature call");
+                    }
+                    CONSTANT_Methodref_info methRef =
+                            (CONSTANT_Methodref_info)cf.constant_pool.get(cp_entry);
+                    String type = methRef.getNameAndTypeInfo().getType();
+                    if (!type.equals(PS_TYPE)) {
+                        throw new Error("Unexpected type in polymorphic signature call: " + type);
+                    }
+                }
+            }
+            if (instr_count != PS_CALLS_COUNT) {
+                throw new Error("Wrong number of polymorphic signature call found: " + instr_count);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw new Error("error reading " + f +": " + e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/parser/ExtraSemiTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,100 @@
+/*
+ * 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 6921495
+ * @summary spurious semicolons in class def cause empty NOPOS blocks
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.tools.*;
+import com.sun.source.util.*;
+
+public class ExtraSemiTest {
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        final static String source =
+                        "class C {\n" +
+                        "    int x;;\n" +
+                        "    class X { int i;; };\n" +
+                        "}";
+
+        JavaSource() {
+            super(URI.create("myfo:/C.java"), JavaFileObject.Kind.SOURCE);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public static void main(String... args) throws IOException {
+        new ExtraSemiTest().run();
+    }
+
+    void run() throws IOException {
+        File destDir = new File("classes"); destDir.mkdir();
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavaSource source = new JavaSource();
+        JavacTask ct = (JavacTask)tool.getTask(null, null, null,
+                Arrays.asList("-d", destDir.getPath(), "-XD-printsource"),
+                null,
+                Arrays.asList(source));
+        Boolean ok = ct.call();
+        if (!ok) throw new AssertionError("compilation failed");
+
+        String text = readFile(new File(destDir, "C.java"));
+        System.out.println(text);
+
+        // compress/canonicalize all whitespace
+        String canon = text.replaceAll("\\s+", " ");
+        System.out.println("canon: " + canon);
+
+        // There are no empty blocks in the original text.
+        // C will be given a default constructor "C() { super(); }" which
+        // does not have any empty blocks.
+        // The bug is that spurious semicolons in the class defn are parsed
+        // into redundant empty blocks in the tree, so verify there are
+        // no empty blocks in the -printsource output
+
+        if (canon.contains("{ }"))
+            throw new AssertionError("unexpected empty block found");
+    }
+
+    String readFile(File f) throws IOException {
+        int len = (int) f.length();
+        byte[] data = new byte[len];
+        DataInputStream in = new DataInputStream(new FileInputStream(f));
+        try {
+            in.readFully(data);
+            return new String(data);
+        } finally {
+            in.close();
+        }
+    }
+}
--- a/test/tools/javac/processing/6348499/A.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6348499/A.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -27,10 +27,8 @@
 import javax.lang.model.*;
 import javax.lang.model.element.*;
 
-@SupportedAnnotationTypes("*")
-public class A extends AbstractProcessor {
+public class A extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
-        Filer filer = processingEnv.getFiler();
         try {
             OutputStream out = filer.createClassFile(getClass().getName()+"_0").openOutputStream();
             out.close();
@@ -39,8 +37,4 @@
         }
         return true;
     }
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/processing/6348499/T6348499.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6348499/T6348499.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -25,7 +25,8 @@
  * @test
  * @bug 6441871
  * @summary javac crashes at com.sun.tools.javac.jvm.ClassReader$BadClassFile
- * @build A
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor A
  * @run main T6348499
  */
 
@@ -54,7 +55,6 @@
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, "A.java")));
         Iterable<String> opts = Arrays.asList("-proc:only",
                                               "-processor", "A",
-                                              "-source", "1.6",
                                               "-processorpath", testClasses);
         StringWriter out = new StringWriter();
         JavacTask task = tool.getTask(out, fm, dl, opts, null, files);
--- a/test/tools/javac/processing/6359313/T6359313.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6359313/T6359313.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug     6359313
  * @summary error compiling annotated package
  * @author  Peter von der Ah\u00e9
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile T6359313.java
  * @compile -processor T6359313 package-info.java Foo.java
  */
@@ -37,7 +39,7 @@
 import javax.lang.model.element.TypeElement;
 
 @SupportedAnnotationTypes("Foo")
-public class T6359313 extends AbstractProcessor {
+public class T6359313 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
         return true;
--- a/test/tools/javac/processing/6365040/ProcBar.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6365040/ProcBar.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -31,13 +31,11 @@
 /**
  * Second of several processors to run.
  */
-@SupportedAnnotationTypes("*")
-public class ProcBar extends AbstractProcessor {
+public class ProcBar extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
         if (!roundEnvironment.processingOver())
-            processingEnv.getMessager().printMessage(NOTE,
-                                                     "Hello from ProcBar");
+            messager.printMessage(NOTE, "Hello from ProcBar");
         return false;
     }
 }
--- a/test/tools/javac/processing/6365040/ProcFoo.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6365040/ProcFoo.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -31,13 +31,11 @@
 /**
  * First of several processors to run.
  */
-@SupportedAnnotationTypes("*")
-public class ProcFoo extends AbstractProcessor {
+public class ProcFoo extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
         if (!roundEnvironment.processingOver())
-            processingEnv.getMessager().printMessage(NOTE,
-                                                     "Hello from ProcFoo");
+            messager.printMessage(NOTE, "Hello from ProcFoo");
         return false;
     }
 }
--- a/test/tools/javac/processing/6365040/T6365040.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6365040/T6365040.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug 6365040 6358129
  * @summary Test -processor foo,bar,baz
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile ProcFoo.java
  * @compile ProcBar.java
  * @compile T6365040.java
@@ -43,13 +45,11 @@
 import javax.lang.model.element.TypeElement;
 import static javax.tools.Diagnostic.Kind.*;
 
-@SupportedAnnotationTypes("*")
-public class T6365040 extends AbstractProcessor {
+public class T6365040 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
         if (!roundEnvironment.processingOver())
-            processingEnv.getMessager().printMessage(NOTE,
-                                                     "Hello from T6365040");
+            messager.printMessage(NOTE, "Hello from T6365040");
         return true;
     }
 }
--- a/test/tools/javac/processing/6413690/T6413690.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6413690/T6413690.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug     6413690 6380018
  * @summary JavacProcessingEnvironment does not enter trees from preceding rounds
  * @author  Peter von der Ah\u00e9
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile T6413690.java
  * @compile -XDfatalEnterError -verbose -processor T6413690 src/Super.java TestMe.java
  */
@@ -42,11 +44,9 @@
 import javax.lang.model.util.Elements;
 
 @SupportedAnnotationTypes("TestMe")
-public class T6413690 extends AbstractProcessor {
+public class T6413690 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
-        Elements elements = processingEnv.getElementUtils();
-        Filer filer = processingEnv.getFiler();
         TypeElement testMe = elements.getTypeElement(TestMe.class.getName());
         Set<? extends Element> supers = roundEnvironment.getElementsAnnotatedWith(testMe);
         try {
--- a/test/tools/javac/processing/6414633/A.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6414633/A.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -29,9 +29,8 @@
 import javax.lang.model.element.*;
 import javax.tools.*;
 
-@SupportedAnnotationTypes("*")
-public class A extends AbstractProcessor {
-
+@SuppressWarnings("")
+public class A extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
         Messager m = processingEnv.getMessager();
         for (TypeElement anno: annotations) {
@@ -42,8 +41,6 @@
         return true;
     }
 
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
+    @SuppressWarnings("")
+    private void foo() {}
 }
--- a/test/tools/javac/processing/6414633/T6414633.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6414633/T6414633.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -25,7 +25,8 @@
  * @test
  * @bug 6414633 6440109
  * @summary Only the first processor message at a source location is reported
- * @build A T6414633
+ * @library ../../lib
+ * @build    JavacTestingAbstractProcessor A T6414633
  * @run main T6414633
  */
 
@@ -55,8 +56,7 @@
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, A.class.getName()+".java")));
         String[] opts = { "-proc:only",
                           "-processor", A.class.getName(),
-                          "-source", "1.6",
-                          "-classpath", testClasses };
+                          "-classpath", testClasses + System.getProperty("path.separator") + "../../lib" };
         JavacTask task = tool.getTask(null, fm, dl, Arrays.asList(opts), null, files);
         task.call();
 
--- a/test/tools/javac/processing/6430209/T6430209.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6430209/T6430209.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -25,7 +25,8 @@
  * @test
  * @bug 6441871
  * @summary spurious compiler error elicited by packageElement.getEnclosedElements()
- * @build b6341534
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor b6341534
  * @run main T6430209
  */
 
@@ -54,7 +55,7 @@
         // run annotation processor b6341534 so we can check diagnostics
         // -proc:only -processor b6341534 -cp . ./src/*.java
         String testSrc = System.getProperty("test.src", ".");
-        String testClasses = System.getProperty("test.classes");
+        String testClasses = System.getProperty("test.classes") + System.getProperty("path.separator") + "../../lib";
         JavacTool tool = JavacTool.create();
         MyDiagListener dl = new MyDiagListener();
         StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
--- a/test/tools/javac/processing/6430209/b6341534.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6430209/b6341534.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -30,16 +30,9 @@
 import java.util.*;
 import java.util.Set;
 
-@SupportedAnnotationTypes({"*"})
-public class b6341534 extends AbstractProcessor {
+public class b6341534 extends JavacTestingAbstractProcessor {
     static int r = 0;
-    static Elements E = null;
-    static Messager msgr = null;
-    public void init(ProcessingEnvironment penv)  {
-        processingEnv = penv;
-        msgr = penv.getMessager();
-        E = penv.getElementUtils();
-    }
+
     //Create directory 'dir1' and a test class in dir1
     public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv)
     {
@@ -49,22 +42,22 @@
                 System.out.println("Round"+r+ ": " + t.toString());
 
             try {
-                PackageElement PE = E.getPackageElement("dir1");
+                PackageElement PE = eltUtils.getPackageElement("dir1");
                 List<? extends Element> LEE = PE.getEnclosedElements();    /* <=This line elicits the error message.  */
-                for(Element e : LEE)    System.out.println("found " + e.toString() + " in dir1.");
+                for(Element e : LEE)
+                    System.out.println("found " + e.toString() + " in dir1.");
             }
             catch(NullPointerException npe) {
-                msgr.printMessage(ERROR,npe.toString());
+                messager.printMessage(ERROR,npe.toString());
                 //npe.printStackTrace();
                 return false;
             }
         }
-        if( renv.errorRaised() ) {      msgr.printMessage(ERROR, "FAILED");}
+        // on round 1, expect errorRaised == false && processingOver == false
+        // on round 2, expect errorRaised == true && processingOver == true
+        if( renv.errorRaised() != renv.processingOver()) {
+            messager.printMessage(ERROR, "FAILED");
+        }
         return true;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/processing/6499119/ClassProcessor.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6499119/ClassProcessor.java	Wed Nov 10 19:07:04 2010 +0000
@@ -32,20 +32,17 @@
  * @test
  * @bug 6499119
  * @summary Created package-info class file modeled improperly
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile ClassProcessor.java package-info.java
  * @compile/process -cp . -processor ClassProcessor -Akind=java  java.lang.Object
  * @compile/process -cp . -processor ClassProcessor -Akind=class java.lang.Object
  */
 
 @SupportedOptions({ "gen", "expect" })
-@SupportedAnnotationTypes({"*"})
-public class ClassProcessor extends AbstractProcessor {
+public class ClassProcessor extends JavacTestingAbstractProcessor {
     int round = 1;
 
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
         if (round == 1) {
             System.out.println("-- Round 1 --");
@@ -71,8 +68,6 @@
     }
 
     private void createPackageFile() {
-        Filer filer = processingEnv.getFiler();
-
         String kind = processingEnv.getOptions().get("kind");
 
         File pkgInfo;
@@ -125,7 +120,6 @@
     }
 
     private void error(String msg) {
-        Messager messager = processingEnv.getMessager();
         messager.printMessage(Kind.ERROR, msg);
     }
 }
--- a/test/tools/javac/processing/6511613/DummyProcessor.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6511613/DummyProcessor.java	Wed Nov 10 19:07:04 2010 +0000
@@ -26,15 +26,10 @@
 import javax.lang.model.element.*;
 import java.util.Set;
 
-@SupportedAnnotationTypes("*")
-public class DummyProcessor extends  AbstractProcessor {
+public class DummyProcessor extends JavacTestingAbstractProcessor {
    public boolean process(Set<? extends TypeElement> annotations,
                   RoundEnvironment roundEnv) {
        return true;
    }
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
 
--- a/test/tools/javac/processing/6511613/clss41701.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6511613/clss41701.java	Wed Nov 10 19:07:04 2010 +0000
@@ -26,7 +26,8 @@
  * @bug 6511613
  * @summary javac unexpectedly doesn't fail in some cases if an annotation processor specified
  *
- * @build DummyProcessor
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor DummyProcessor
  * @compile/fail clss41701.java
  * @compile/fail -processor DummyProcessor clss41701.java
  */
--- a/test/tools/javac/processing/6512707/T6512707.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6512707/T6512707.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,8 +26,9 @@
  * @bug 6512707
  * @summary "incompatible types" after (unrelated) annotation processing
  * @author  Peter Runge
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile T6512707.java
- *
  * @compile -processor T6512707 TestAnnotation.java
  */
 
@@ -41,16 +42,10 @@
  * Dummy processor to force bug 6512707 to show - it does not matter what
  * the annotation processor does for this bug.
  */
-@SupportedAnnotationTypes("*")
-public class T6512707 extends AbstractProcessor {
+public class T6512707 extends JavacTestingAbstractProcessor {
 
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
-        return(false);
-    }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
+        return false;
     }
 }
--- a/test/tools/javac/processing/6634138/T6634138.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/6634138/T6634138.java	Wed Nov 10 19:07:04 2010 +0000
@@ -26,6 +26,8 @@
  * @bug 6634138
  * @author  Joseph D. Darcy
  * @summary Verify source files output after processing is over are compiled
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile T6634138.java
  * @compile -processor T6634138 Dummy.java
  * @run main ExerciseDependency
@@ -44,10 +46,7 @@
 import javax.lang.model.element.*;
 import javax.lang.model.util.*;
 
-@SupportedAnnotationTypes("*")
-public class T6634138 extends AbstractProcessor {
-    private Filer filer;
-
+public class T6634138 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
         // Write out files *after* processing is over.
@@ -77,16 +76,6 @@
         }
         return true;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        filer    = processingEnv.getFiler();
-    }
 }
 
 
--- a/test/tools/javac/processing/T6439826.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/T6439826.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -48,8 +48,7 @@
         StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
         Iterable<? extends JavaFileObject> files =
             fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6439826.class.getName()+".java")));
-        Iterable<String> opts = Arrays.asList("-source","1.6",
-                                              "-proc:only",
+        Iterable<String> opts = Arrays.asList("-proc:only",
                                               "-processor", "T6439826",
                                               "-processorpath", testClasses);
         StringWriter out = new StringWriter();
--- a/test/tools/javac/processing/T6920317.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/T6920317.java	Wed Nov 10 19:07:04 2010 +0000
@@ -25,6 +25,7 @@
  * @test
  * @bug 6920317
  * @summary package-info.java file has to be specified on the javac cmdline, else it will not be avail
+ * @library ../lib
  */
 
 import java.io.*;
@@ -349,12 +350,7 @@
     /** Annotation processor used to verify the expected value for the
         package annotations found by javac. */
     @SupportedOptions({ "gen", "expect" })
-    @SupportedAnnotationTypes({"*"})
-    public static class Processor extends AbstractProcessor {
-        public SourceVersion getSupportedSourceVersion() {
-            return SourceVersion.latest();
-        }
-
+    public static class Processor extends JavacTestingAbstractProcessor {
         public boolean process(Set<? extends TypeElement> annots, RoundEnvironment renv) {
             round++;
             System.err.println("Round " + round + " annots:" + annots + " rootElems:" + renv.getRootElements());
--- a/test/tools/javac/processing/Xprint.java	Tue Sep 14 11:37:19 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2005, 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     6266828
- * @summary JSR 269: Java Language Model API
- * @author  Peter von der Ah\u00e9
- */
-import javax.tools.JavaCompiler;
-import javax.tools.ToolProvider;
-
-public class Xprint {
-    public static void main(String[] args) {
-        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
-        javac.run(System.in, null, null,
-                  "-Xprint",
-                  "com.sun.tools.javac.code.Types",
-                  "com.sun.tools.javac.parser.Parser",
-                  "java.util.EnumSet");
-    }
-}
--- a/test/tools/javac/processing/environment/TestSourceVersion.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/environment/TestSourceVersion.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug 6402506
  * @summary Test that getSourceVersion works properly
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile TestSourceVersion.java
  * @compile -processor TestSourceVersion -proc:only -source 1.2 -AExpectedVersion=RELEASE_2 HelloWorld.java
  * @compile -processor TestSourceVersion -proc:only -source 1.3 -AExpectedVersion=RELEASE_3 HelloWorld.java
@@ -52,9 +54,8 @@
  * This processor checks that ProcessingEnvironment.getSourceVersion()
  * is consistent with the setting of the -source option.
  */
-@SupportedAnnotationTypes("*")
 @SupportedOptions("ExpectedVersion")
-public class TestSourceVersion extends AbstractProcessor {
+public class TestSourceVersion extends JavacTestingAbstractProcessor {
 
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
@@ -68,9 +69,4 @@
 
         return true;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/environment/round/TestContext.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,96 @@
+/*
+ * 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 6988836
+ * @summary A new JavacElements is created for each round of annotation processing
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestContext
+ * @compile/process -processor TestContext -XprintRounds TestContext
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+import static javax.tools.Diagnostic.Kind.*;
+
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTrees;
+import com.sun.tools.javac.model.JavacElements;
+import com.sun.tools.javac.model.JavacTypes;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+
+public class TestContext extends JavacTestingAbstractProcessor {
+
+    Trees treeUtils;
+    int round = 0;
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        treeUtils = Trees.instance(processingEnv);
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+
+        JavacProcessingEnvironment jpe = (JavacProcessingEnvironment) processingEnv;
+        Context c = jpe.getContext();
+        check(c.get(JavacElements.class), eltUtils);
+        check(c.get(JavacTypes.class), typeUtils);
+        check(c.get(JavacTrees.class), treeUtils);
+
+        final int MAXROUNDS = 3;
+        if (round < MAXROUNDS)
+            generateSource("Gen" + round);
+
+        return true;
+    }
+
+    <T> void check(T actual, T expected) {
+//        messager.printMessage(NOTE, "expect: " + expected);
+//        messager.printMessage(NOTE, "actual: " + actual);
+
+        if (actual != expected) {
+            messager.printMessage(ERROR,
+                "round " + round + " unexpected value for " + expected.getClass().getName() + ": " + actual);
+        }
+    }
+
+    void generateSource(String name) {
+        String text = "class " + name + " { }\n";
+
+        try (Writer out = filer.createSourceFile(name).openWriter()) {
+                out.write(text);
+        } catch (IOException e) {
+            throw new Error(e);
+        }
+    }
+
+}
+
--- a/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/environment/round/TestElementsAnnotatedWith.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2009, 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
@@ -26,6 +26,8 @@
  * @bug 6397298 6400986 6425592 6449798 6453386 6508401 6498938 6911854
  * @summary Tests that getElementsAnnotatedWith works properly.
  * @author  Joseph D. Darcy
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile TestElementsAnnotatedWith.java
  * @compile InheritedAnnotation.java
  * @compile -processor TestElementsAnnotatedWith -proc:only SurfaceAnnotations.java
@@ -57,16 +59,13 @@
  * getElementsAnnotatedWith is consistent with the expected results
  * stored in an AnnotatedElementInfo annotation.
  */
-@SupportedAnnotationTypes("*")
 @AnnotatedElementInfo(annotationName="java.lang.SuppressWarnings", expectedSize=0, names={})
-public class TestElementsAnnotatedWith extends AbstractProcessor {
+public class TestElementsAnnotatedWith extends JavacTestingAbstractProcessor {
 
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
-        Elements elementUtils = processingEnv.getElementUtils();
-
         TypeElement annotatedElementInfoElement =
-            elementUtils.getTypeElement("AnnotatedElementInfo");
+            elements.getTypeElement("AnnotatedElementInfo");
         Set<? extends Element> resultsMeta = Collections.emptySet();
         Set<? extends Element> resultsBase = Collections.emptySet();
 
@@ -93,9 +92,7 @@
 
                 resultsMeta =
                     roundEnvironment.
-                    getElementsAnnotatedWith(elementUtils.
-                                             getTypeElement(annotatedElementInfo.
-                                                            annotationName())) ;
+                    getElementsAnnotatedWith(elements.getTypeElement(annotatedElementInfo.annotationName()));
 
                 System.err.println("Results: " + resultsMeta);
 
@@ -167,9 +164,4 @@
             throw new RuntimeException("Illegal argument exception not thrown");
         } catch(IllegalArgumentException iae) {}
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/errors/TestFatalityOfParseErrors.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,9 @@
  * @bug 6403459
  * @summary Test that generating programs with syntax errors is a fatal condition
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
+ * @compile TestReturnCode.java
  * @compile TestFatalityOfParseErrors.java
  * @compile/fail -XprintRounds -processor TestFatalityOfParseErrors -proc:only TestFatalityOfParseErrors.java
  */
@@ -45,11 +48,8 @@
  * Write out an incomplete source file and observe that the next round
  * is marked as an error.
  */
-@SupportedAnnotationTypes("*")
-public class TestFatalityOfParseErrors extends AbstractProcessor {
+public class TestFatalityOfParseErrors extends JavacTestingAbstractProcessor {
     int round = 0;
-    Messager messager;
-    Filer filer;
 
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
@@ -87,14 +87,4 @@
         }
         return true;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        messager = processingEnv.getMessager();
-        filer    = processingEnv.getFiler();
-    }
 }
--- a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug 6406212
  * @summary Test that annotation processor options with illegal syntax are rejected
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile TestOptionSyntaxErrors.java
  * @compile/fail -A TestOptionSyntaxErrors.java
  * @compile/fail -A8adOption TestOptionSyntaxErrors.java
@@ -46,14 +48,9 @@
 /**
  * No-op processor; should not be run.
  */
-@SupportedAnnotationTypes("*")
-public class TestOptionSyntaxErrors extends AbstractProcessor {
+public class TestOptionSyntaxErrors extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment) {
         return true;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/errors/TestParseErrors/ParseErrors.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,42 @@
+/*
+ * 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.List;
+import java.util.Vector;
+
+class test {
+
+    public String m(List<? extends String> v, String s ) {
+        return null;
+    }
+
+    public String m2(Vector<String> vs, String s) {
+        return null;
+    }
+
+    public void m3(testclass<String>,
+}
+
+class testclass<T> {
+    T t;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6988407
+ * @summary javac crashes running processor on errant code; it used to print error message
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestParseErrors
+ * @compile/fail/ref=TestParseErrors.out -XDrawDiagnostics -proc:only -processor TestParseErrors ParseErrors.java
+ */
+
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+
+public class TestParseErrors extends JavacTestingAbstractProcessor {
+
+    public boolean process(Set<? extends TypeElement> annotations,
+                           RoundEnvironment roundEnvironment) {
+        throw new Error("Should not be called");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,8 @@
+ParseErrors.java:37:37: compiler.err.expected: token.identifier
+ParseErrors.java:38:1: compiler.err.illegal.start.of.type
+ParseErrors.java:38:2: compiler.err.expected: ')'
+ParseErrors.java:40:6: compiler.err.expected: ';'
+ParseErrors.java:40:20: compiler.err.illegal.start.of.type
+ParseErrors.java:41:5: compiler.err.expected: '('
+ParseErrors.java:41:8: compiler.err.expected: token.identifier
+7 errors
--- a/test/tools/javac/processing/errors/TestReturnCode.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/errors/TestReturnCode.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug 6403468
  * @summary Test that an erroneous return code results from raising an error.
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile TestReturnCode.java
  *
  * @compile      -processor TestReturnCode -proc:only                                                                   Foo.java
@@ -60,20 +62,17 @@
  * This processor raises errors or throws exceptions on different
  * rounds to allow the return code to be test.
  */
-@SupportedAnnotationTypes("*")
 @SupportedOptions({"ErrorOnFirst",
                    "ErrorOnLast",
                    "ExceptionOnFirst",
                    "ExceptionOnLast"})
-public class TestReturnCode extends AbstractProcessor {
+public class TestReturnCode extends JavacTestingAbstractProcessor {
 
     private boolean errorOnFirst;
     private boolean errorOnLast;
     private boolean exceptionOnFirst;
     private boolean exceptionOnLast;
 
-    private Messager messager;
-
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
         if (!roundEnv.processingOver()) {
@@ -103,11 +102,5 @@
         errorOnLast     = keySet.contains("ErrorOnLast");
         exceptionOnFirst  = keySet.contains("ExceptionOnFirst");
         exceptionOnLast = keySet.contains("ExceptionOnLast");
-        messager = processingEnv.getMessager();
-    }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/errors/TestSuppression.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,232 @@
+/*
+ * 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 6403465
+ * @summary javac should defer diagnostics until it can be determined they are persistent
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.TypeElement;
+import javax.tools.*;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.util.JCDiagnostic;
+
+import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*;
+
+
+public class TestSuppression {
+    public static void main(String... args) throws Exception {
+        new TestSuppression().run(args);
+    }
+
+    enum WarningKind { NO, YES };
+
+    String[] cases = {
+        // missing class C
+        "class X { C c; }",
+        "class X { C foo() { return null; } }",
+        "class X { void foo(C c) { } }",
+        "class X extends C { }",
+        "class X<T extends C> { }",
+        // missing interface I
+        "class X implements I { }",
+        "interface X extends I { }",
+        // missing exception E
+        "class X { void m() throws E { } }",
+        // missing method m
+        "class X extends C { int i = m(); }",
+        // missing field f
+        "class X extends C { int i = f; }"
+    };
+
+    void run(String... args) throws Exception {
+        for (String c: cases) {
+            for (WarningKind wk: WarningKind.values()) {
+                for (int g = 1; g <= 3; g++) {
+                    try {
+                        test(c, wk, g);
+                    } catch (Throwable t) {
+                        error("caught: " + t);
+                    }
+                    if (errors > 0) throw new AssertionError();
+                }
+            }
+        }
+
+        System.err.println(count + " test cases");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(String src, WarningKind wk, int gen) throws Exception {
+        count++;
+        System.err.println("Test " + count + ": wk:" + wk + " gen:" + gen + " src:" +src);
+
+        File testDir = new File("test" + count);
+        File srcDir = createDir(testDir, "src");
+        File gensrcDir = createDir(testDir, "gensrc");
+        File classesDir = createDir(testDir, "classes");
+
+        File x = writeFile(new File(srcDir, "X.java"), src);
+
+        DiagListener dl = new DiagListener();
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(dl, null, null);
+        fm.setLocation(StandardLocation.CLASS_PATH,
+                Arrays.asList(classesDir, new File(System.getProperty("test.classes"))));
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Collections.singleton(classesDir));
+        fm.setLocation(StandardLocation.SOURCE_OUTPUT, Collections.singleton(gensrcDir));
+        List<String> args = new ArrayList<String>();
+//        args.add("-XprintProcessorInfo");
+        args.add("-XprintRounds");
+        args.add("-Agen=" + gen);
+        if (wk == WarningKind.YES)
+            args.add("-Xlint:serial");
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(x);
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        JavacTask task = tool.getTask(pw, fm, dl, args, null, files);
+        task.setProcessors(Arrays.asList(new AnnoProc()));
+        boolean ok = task.call();
+        pw.close();
+
+        System.err.println("ok:" + ok + " diags:" + dl.counts);
+        if (sw.toString().length() > 0) {
+            System.err.println("output:\n" + sw.toString());
+        }
+
+        for (Diagnostic.Kind dk: Diagnostic.Kind.values()) {
+            Integer v = dl.counts.get(dk);
+            int found = (v == null) ? 0 : v;
+            int expect = (dk == Diagnostic.Kind.WARNING && wk == WarningKind.YES) ? gen : 0;
+            if (found != expect) {
+                error("Unexpected value for " + dk + ": expected: " + expect + " found: " + found);
+            }
+        }
+
+        System.err.println();
+    }
+
+    File createDir(File parent, String name) {
+        File dir = new File(parent, name);
+        dir.mkdirs();
+        return dir;
+    }
+
+    File writeFile(File f, String content) throws IOException {
+        FileWriter out = new FileWriter(f);
+        try {
+            out.write(content);
+        } finally {
+            out.close();
+        }
+        return f;
+    }
+
+    <T> void add(List<T> list, T... values) {
+        for (T v: values)
+            list.add(v);
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int count;
+    int errors;
+
+    static class DiagListener implements DiagnosticListener<JavaFileObject> {
+        int total;
+        Map<Diagnostic.Kind,Integer> counts = new TreeMap<Diagnostic.Kind,Integer>();
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            System.err.println((++total) + ": "
+                    + "resolveError:" + isResolveError((JCDiagnostic) diagnostic) + "\n"
+                    + diagnostic);
+            Diagnostic.Kind dk = diagnostic.getKind();
+            Integer c = counts.get(dk);
+            counts.put(dk, (c == null ? 1 : c + 1));
+        }
+
+        private static boolean isResolveError(JCDiagnostic d) {
+            return d.isFlagSet(RESOLVE_ERROR);
+        }
+    }
+
+    @SupportedAnnotationTypes("*")
+    @SupportedOptions("gen")
+    public static class AnnoProc extends AbstractProcessor {
+        Filer f;
+        Messager m;
+        int gen;
+
+        @Override
+        public void init(ProcessingEnvironment processingEnv) {
+            f = processingEnv.getFiler();
+            m = processingEnv.getMessager();
+            Map<String,String> options = processingEnv.getOptions();
+            gen = Integer.parseInt(options.get("gen"));
+        }
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            round++;
+            if (round < gen)
+                writeSource("Dummy" + round, "class Dummy" + round + " extends java.util.ArrayList{ }");
+            else if (round == gen) {
+                writeSource("C", "class C { int f; int m() { return 0; } }");
+                writeSource("I", "interface I { }");
+                writeSource("E", "class E extends Exception { }");
+            }
+            return true;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+
+        private void writeSource(String name, String text) {
+            try {
+                JavaFileObject fo = f.createSourceFile(name);
+                Writer out = fo.openWriter();
+                out.write(text);
+                out.close();
+            } catch (IOException e) {
+                m.printMessage(Diagnostic.Kind.ERROR, e.toString());
+            }
+        }
+
+        int round = 0;
+    }
+}
--- a/test/tools/javac/processing/filer/TestFilerConstraints.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/filer/TestFilerConstraints.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,7 @@
  * @bug 6380018 6453386 6457283
  * @summary Test that the constraints guaranteed by the Filer and maintained
  * @author  Joseph D. Darcy
+ * @library ../../lib
  * @build TestFilerConstraints
  * @compile -encoding iso-8859-1 -processor TestFilerConstraints -proc:only TestFilerConstraints.java
  */
@@ -69,11 +70,8 @@
  *
  * </ul>
  */
-@SupportedAnnotationTypes("*")
-public class TestFilerConstraints extends AbstractProcessor {
+public class TestFilerConstraints extends JavacTestingAbstractProcessor {
     private int round = 0;
-    private Messager messager;
-    private Filer filer;
 
     private PrintWriter  pw_src1 = null;
     private PrintWriter  pw_src2 = null;
@@ -167,17 +165,6 @@
         return true;
     }
 
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        messager = processingEnv.getMessager();
-        filer    = processingEnv.getFiler();
-
-    }
-
     /**
      * Test that the single expected expected type, name, is the root
      * element.
--- a/test/tools/javac/processing/filer/TestGetResource.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/filer/TestGetResource.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug 6380018 6449798
  * @summary Test Filer.getResource
  * @author  Joseph D. Darcy
- * @build TestGetResource
+ * @library ../../lib
+ * @build  JavacTestingAbstractProcessor TestGetResource
  * @compile -processor TestGetResource -proc:only -Aphase=write TestGetResource.java
  * @compile -processor TestGetResource -proc:only -Aphase=read  TestGetResource.java
  */
@@ -49,13 +50,8 @@
  * first run of the annotation processor, write out a resource file
  * and on the second run read it in.
  */
-@SupportedAnnotationTypes("*")
 @SupportedOptions("phase")
-public class TestGetResource extends AbstractProcessor {
-    private Messager messager;
-    private Filer filer;
-    private Map<String,String> options;
-
+public class TestGetResource extends JavacTestingAbstractProcessor {
     private static String CONTENTS = "Hello World.";
     private static String PKG = "";
     private static String RESOURCE_NAME = "Resource1";
@@ -92,15 +88,4 @@
         }
         return false;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        messager = processingEnv.getMessager();
-        filer    = processingEnv.getFiler();
-        options  = processingEnv.getOptions();
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/filer/TestGetResource2.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 6929404
+ * @summary Filer.getResource(SOURCE_PATH, ...) does not work when -sourcepath contains >1 entry
+ * @library ../../lib
+ */
+
+import java.io.*;
+import java.security.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler.CompilationTask;
+
+public class TestGetResource2 {
+
+    public static void main(String[] args) throws Exception {
+        new TestGetResource2().run();
+    }
+
+    void run() throws Exception {
+        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        CodeSource cs = javac.getClass().getProtectionDomain().getCodeSource();
+        if (cs == null) {
+            System.err.println("got compiler from " +
+                ClassLoader.getSystemResource(javac.getClass().getName().replace(".", "/")+".class"));
+        } else {
+            System.err.println("got compiler from " + cs.getLocation());
+        }
+
+        testSingleSourceDir(javac);
+        testCompositeSourcePath(javac);
+        testMissingResource(javac);
+    }
+
+    private void testSingleSourceDir(JavaCompiler javac) throws Exception {
+        System.err.println("testSingleSourceDir");
+        File tmpdir = new File("testSingleSourceDir");
+        File srcdir = new File(tmpdir, "src");
+        File destdir = new File(tmpdir, "dest");
+        write(srcdir, "pkg/X.java", "package pkg; class X {}");
+        write(srcdir, "resources/file.txt", "hello");
+        destdir.mkdirs();
+
+        CompilationTask task = javac.getTask(null, null, null,
+                Arrays.asList("-sourcepath", srcdir.toString(), "-d", destdir.toString()),
+                Collections.singleton("pkg.X"), null);
+        task.setProcessors(Collections.singleton(new AnnoProc()));
+        boolean result = task.call();
+        System.err.println("javac result with single source dir: " + result);
+        expect(result, true);
+    }
+
+    private void testCompositeSourcePath(JavaCompiler javac) throws Exception {
+        System.err.println("testCompositeSearchPath");
+        File tmpdir = new File("testCompositeSourcePath");
+        File srcdir = new File(tmpdir, "src");
+        File rsrcdir = new File(tmpdir, "rsrc");
+        File destdir = new File(tmpdir, "dest");
+        write(srcdir, "pkg/X.java", "package pkg; class X {}");
+        write(rsrcdir, "resources/file.txt", "hello");
+        destdir.mkdirs();
+
+        CompilationTask task = javac.getTask(null, null, null,
+                Arrays.asList("-sourcepath", srcdir + File.pathSeparator + rsrcdir, "-d", destdir.toString()),
+                Collections.singleton("pkg.X"), null);
+        task.setProcessors(Collections.singleton(new AnnoProc()));
+        boolean result = task.call();
+        System.err.println("javac result with composite source path: " + result);
+        expect(result, true);
+    }
+
+    private void testMissingResource(JavaCompiler javac) throws Exception {
+        System.err.println("testMissingResource");
+        File tmpdir = new File("testMissingResource");
+        File srcdir = new File(tmpdir, "src");
+        File destdir = new File(tmpdir, "dest");
+        write(srcdir, "pkg/X.java", "package pkg; class X {}");
+        destdir.mkdirs();
+
+        CompilationTask task = javac.getTask(null, null, null,
+                Arrays.asList("-sourcepath", srcdir.toString(), "-d", destdir.toString()),
+                Collections.singleton("pkg.X"), null);
+        task.setProcessors(Collections.singleton(new AnnoProc()));
+        boolean result = task.call();
+        System.err.println("javac result when missing resource: " + result);
+        expect(result, false);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static class AnnoProc extends JavacTestingAbstractProcessor {
+
+        public @Override boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.processingOver()) {
+                return false;
+            }
+
+            try {
+                FileObject resource = filer.getResource(StandardLocation.SOURCE_PATH, "resources", "file.txt");
+                try {
+                    resource.openInputStream().close();
+                    messager.printMessage(Kind.NOTE, "found: " + resource.toUri());
+                    return true;
+                } catch (IOException x) {
+                    messager.printMessage(Kind.ERROR, "could not read: " + resource.toUri());
+                    x.printStackTrace();
+                }
+            } catch (IOException x) {
+                messager.printMessage(Kind.ERROR, "did not find resource");
+                x.printStackTrace();
+            }
+
+            return false;
+        }
+
+    }
+
+    private File write(File dir, String path, String contents) throws IOException {
+        File f = new File(dir, path);
+        f.getParentFile().mkdirs();
+        Writer w = new FileWriter(f);
+        try {
+            w.write(contents);
+        } finally {
+            w.close();
+        }
+        return f;
+    }
+
+    void expect(boolean val, boolean expect) {
+        if (val != expect)
+            error("Unexpected value: " + val + "; expected: " + expect);
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/filer/TestInvalidRelativeNames.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,100 @@
+/*
+ * 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 6502392
+ * @summary Invalid relative names for Filer.createResource and Filer.getResource
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
+ * @compile TestInvalidRelativeNames.java
+ * @compile/process -processor TestInvalidRelativeNames java.lang.Object
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.Diagnostic;
+import javax.tools.StandardLocation;
+
+public class TestInvalidRelativeNames extends JavacTestingAbstractProcessor {
+    enum Kind { CREATE_WRITER, GET_READER, CREATE_OUTPUT_STREAM, GET_INPUT_STREAM };
+
+    static final String[] invalidRelativeNames = {
+            "/boo", "goo/../hoo", "./ioo", ""
+    };
+
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (roundEnv.processingOver()) {
+            for (String relative: invalidRelativeNames) {
+                for (Kind kind: Kind.values()) {
+                    test(relative, kind);
+                }
+            }
+        }
+        return true;
+    }
+
+    void test(String relative, Kind kind) {
+        System.out.println("test relative path: " + relative + ", kind: " + kind);
+        try {
+            switch (kind) {
+                case CREATE_WRITER:
+                    Writer writer = filer.createResource(
+                            StandardLocation.SOURCE_OUTPUT, "", relative).openWriter();
+                    writer.close();
+                    break;
+
+                case GET_READER:
+                    Reader reader = filer.getResource(
+                            StandardLocation.SOURCE_OUTPUT, "", relative).openReader(true);
+                    reader.close();
+                    break;
+
+                case CREATE_OUTPUT_STREAM:
+                    OutputStream out = filer.createResource(
+                            StandardLocation.SOURCE_OUTPUT, "", relative).openOutputStream();
+                    out.close();
+                    break;
+
+                case GET_INPUT_STREAM:
+                    InputStream in = filer.createResource(
+                            StandardLocation.SOURCE_OUTPUT, "", relative).openInputStream();
+                    in.close();
+                    break;
+            }
+        } catch (IllegalArgumentException expected) {
+            System.out.println("expected exception thrown: " + expected);
+            return;
+        } catch (Exception e) {
+            messager.printMessage(Diagnostic.Kind.ERROR,
+                    "relative path: " + relative + ", kind: " + kind + ", unexpected exception: " + e);
+            return;
+        }
+        messager.printMessage(Diagnostic.Kind.ERROR,
+                "relative path: " + relative + ", kind: " + kind + ", no exception thrown");
+    }
+}
+
--- a/test/tools/javac/processing/filer/TestLastRound.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/filer/TestLastRound.java	Wed Nov 10 19:07:04 2010 +0000
@@ -24,6 +24,8 @@
 /*
  * @test 6966604
  * @summary JavacFiler not correctly notified of lastRound
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile TestLastRound.java
  * @compile/fail/ref=TestLastRound.out -XDrawDiagnostics -Werror -proc:only -processor TestLastRound TestLastRound.java
  */
@@ -35,12 +37,10 @@
 import javax.lang.model.element.*;
 import javax.tools.*;
 
-@SupportedAnnotationTypes("*")
-public class TestLastRound extends AbstractProcessor {
+public class TestLastRound extends JavacTestingAbstractProcessor {
     @Override
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
-        Filer filer = processingEnv.getFiler();
         if (roundEnv.processingOver()) {
             try {
                 JavaFileObject fo = filer.createSourceFile("LastRound.java");
@@ -52,9 +52,4 @@
         }
         return true;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/processing/filer/TestPackageInfo.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/filer/TestPackageInfo.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug 6380018 6392177
  * @summary Test the ability to create and process package-info.java files
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile TestPackageInfo.java
  * @compile -processor TestPackageInfo -proc:only foo/bar/package-info.java TestPackageInfo.java
  */
@@ -49,13 +51,7 @@
  * 1) Visibility of package-info files from the command line
  * 2) Visibility of generated package-info.java source files
  */
-@SupportedAnnotationTypes("*")
-public class TestPackageInfo extends AbstractProcessor {
-    private Elements eltUtils;
-    private Messager messager;
-    private Filer filer;
-    private Map<String,String> options;
-
+public class TestPackageInfo extends JavacTestingAbstractProcessor {
     private int round = 0;
 
     public boolean process(Set<? extends TypeElement> annotations,
@@ -64,11 +60,7 @@
 
         // Verify annotations are as expected
         Set<TypeElement> expectedAnnotations = new HashSet<TypeElement>();
-        if (round == 1)
-            expectedAnnotations.add(eltUtils.
-                                    getTypeElement("javax.annotation.processing.SupportedAnnotationTypes"));
-        expectedAnnotations.add(eltUtils.
-                                getTypeElement("java.lang.SuppressWarnings"));
+        expectedAnnotations.add(eltUtils.getTypeElement("java.lang.SuppressWarnings"));
 
         if (!roundEnv.processingOver()) {
             System.out.println("\nRound " + round);
@@ -127,16 +119,4 @@
         }
         return false;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        eltUtils = processingEnv.getElementUtils();
-        messager = processingEnv.getMessager();
-        filer    = processingEnv.getFiler();
-        options  = processingEnv.getOptions();
-    }
 }
--- a/test/tools/javac/processing/messager/6362067/T6362067.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/messager/6362067/T6362067.java	Wed Nov 10 19:07:04 2010 +0000
@@ -2,39 +2,34 @@
  * @test  /nodynamiccopyright/
  * @bug     6362067
  * @summary Messager methods do not print out source position information
- * @build   T6362067
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor T6362067
  * @compile -processor T6362067 -proc:only T6362067.java
  * @compile/ref=T6362067.out -XDrawDiagnostics -processor T6362067 -proc:only T6362067.java
  */
-
 import java.util.Set;
 import javax.annotation.processing.*;
 import javax.lang.model.element.*;
 import static javax.tools.Diagnostic.Kind.*;
 
-@Deprecated // convenient test annotation
-@SupportedAnnotationTypes("*")
-public class T6362067 extends AbstractProcessor {
+@Deprecated // convenient test annotations
+@SuppressWarnings({""})
+public class T6362067 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annos,
                            RoundEnvironment roundEnv) {
-        Messager msgr = processingEnv.getMessager();
+
         for (Element e: roundEnv.getRootElements()) {
-            msgr.printMessage(NOTE, "note:elem", e);
+            messager.printMessage(NOTE, "note:elem", e);
             for (AnnotationMirror a: e.getAnnotationMirrors()) {
-                msgr.printMessage(NOTE, "note:anno", e, a);
+                messager.printMessage(NOTE, "note:anno", e, a);
                 for (AnnotationValue v: a.getElementValues().values()) {
-                    msgr.printMessage(NOTE, "note:value", e, a, v);
+                    messager.printMessage(NOTE, "note:value", e, a, v);
                 }
-
             }
         }
+
         if (roundEnv.processingOver())
-            msgr.printMessage(NOTE, "note:nopos");
+            messager.printMessage(NOTE, "note:nopos");
         return true;
     }
-
-    @Override
-    public javax.lang.model.SourceVersion getSupportedSourceVersion() {
-        return javax.lang.model.SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/processing/messager/MessagerBasics.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/messager/MessagerBasics.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006, 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
@@ -26,6 +26,8 @@
  * @bug     6341173 6341072
  * @summary Test presence of Messager methods
  * @author  Joseph D. Darcy
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile MessagerBasics.java
  * @compile -processor MessagerBasics -proc:only MessagerBasics.java
  * @compile/fail -processor MessagerBasics -proc:only -AfinalError MessagerBasics.java
@@ -39,18 +41,16 @@
 import javax.lang.model.util.*;
 import static javax.tools.Diagnostic.Kind.*;
 
-@SupportedAnnotationTypes("*")
 @SupportedOptions("finalError")
-public class MessagerBasics extends AbstractProcessor {
+public class MessagerBasics extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
-        Messager m = processingEnv.getMessager();
         if (roundEnv.processingOver()) {
             if (processingEnv.getOptions().containsKey("finalError"))
-                m.printMessage(ERROR,   "Does not compute");
+                messager.printMessage(ERROR,   "Does not compute");
             else {
-                m.printMessage(NOTE,    "Post no bills");
-                m.printMessage(WARNING, "Beware the ides of March!");
+                messager.printMessage(NOTE,    "Post no bills");
+                messager.printMessage(WARNING, "Beware the ides of March!");
             }
         }
         return true;
--- a/test/tools/javac/processing/model/6194785/T6194785.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/6194785/T6194785.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug     6194785
  * @summary ParameterDeclaration.getSimpleName does not return actual name from class files
  * @author  Peter von der Ah\u00e9
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile -g T6194785.java T6194785a.java
  * @compile -processor T6194785 foo.T6194785a T6194785.java
  */
@@ -36,13 +38,10 @@
 import javax.lang.model.util.*;
 import static javax.tools.Diagnostic.Kind.*;
 
-@SupportedAnnotationTypes("*")
-public class T6194785 extends AbstractProcessor {
+public class T6194785 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnvironment)
     {
-        final Messager log = processingEnv.getMessager();
-        final Elements elements = processingEnv.getElementUtils();
         class Scan extends ElementScanner7<Void,Void> {
             @Override
             public Void visitExecutable(ExecutableElement e, Void ignored) {
--- a/test/tools/javac/processing/model/6341534/T6341534.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/6341534/T6341534.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -27,6 +27,8 @@
  * @summary PackageElement.getEnclosedElements results in NullPointerException from parse(JavaCompiler.java:429)
  * @author  Steve Sides
  * @author  Peter von der Ahe
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile T6341534.java
  * @compile -proc:only -processor T6341534 dir/package-info.java
  * @compile -processor T6341534 dir/package-info.java
@@ -40,20 +42,11 @@
 import java.util.Set;
 import static javax.tools.Diagnostic.Kind.*;
 
-@SupportedAnnotationTypes("*")
-public class T6341534 extends AbstractProcessor {
-    Elements elements;
-    Messager messager;
-    public void init(ProcessingEnvironment penv)  {
-        super.init(penv);
-        elements = penv.getElementUtils();
-        messager = processingEnv.getMessager();
-    }
-
+public class T6341534 extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv)  {
         messager.printMessage(NOTE,
-                              String.valueOf(elements.getPackageElement("no.such.package")));
-        PackageElement dir = elements.getPackageElement("dir");
+                              String.valueOf(eltUtils.getPackageElement("no.such.package")));
+        PackageElement dir = eltUtils.getPackageElement("dir");
         messager.printMessage(NOTE, dir.getQualifiedName().toString());
         for (Element e : dir.getEnclosedElements())
             messager.printMessage(NOTE, e.toString());
--- a/test/tools/javac/processing/model/element/TestAnonClassNames.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/element/TestAnonClassNames.java	Wed Nov 10 19:07:04 2010 +0000
@@ -26,9 +26,9 @@
  * @bug 6449781
  * @summary Test that reported names of anonymous classes are non-null.
  * @author  Joseph D. Darcy
- * @build TestAnonSourceNames
- * @compile/fail -processor TestAnonSourceNames TestAnonClassNames.java
- * @build TestAnonClassNames
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TestAnonSourceNames
+ * @compile -processor TestAnonSourceNames TestAnonClassNames.java
  * @run main TestAnonClassNames
  */
 
@@ -40,10 +40,6 @@
  *
  * Source files will be tested by the @compile line which runs
  * TestAnonSourceNames as an annotation processor over this file.
- * This compile line is expected to fail until 6930507 is fixed.  Once
- * bug 6930507 is fixed, the "@compile/fail -processor ..." and
- * following "@build..." steps can be replaced with a single "@compile
- * -processor ..." directive.
  *
  * Class files are tested by the @run command on this type.  This
  * class gets the names of classes with different nesting kinds,
@@ -146,8 +142,7 @@
 /**
  * Probe at the various kinds of names of a type element.
  */
-@SupportedAnnotationTypes("*")
-class ClassNameProber extends AbstractProcessor {
+class ClassNameProber extends JavacTestingAbstractProcessor {
     public ClassNameProber(){super();}
 
     private boolean classesFound=false;
@@ -179,8 +174,4 @@
         }
         return true;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/processing/model/element/TestAnonSourceNames.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/element/TestAnonSourceNames.java	Wed Nov 10 19:07:04 2010 +0000
@@ -36,8 +36,7 @@
  * Using the tree API, retrieve element representations of anonymous
  * classes and verify their names are as specified.
  */
-@SupportedAnnotationTypes("*")
-public class TestAnonSourceNames extends AbstractProcessor {
+public class TestAnonSourceNames extends JavacTestingAbstractProcessor {
 
    public boolean process(Set<? extends TypeElement> annotations,
                           RoundEnvironment roundEnv) {
@@ -67,7 +66,7 @@
                      Element element = trees.getElement(trees.getPath(cu, node));
            if (element == null) {
                processingEnv.getMessager().printMessage(ERROR,
-                                                        "No element retreived for node named ''" +
+                                                        "No element retrieved for node named ''" +
                                                         node.getSimpleName() + "''.");
            } else {
 
@@ -84,9 +83,4 @@
            return super.visitClass(node, cu);
        }
    }
-
-   @Override
-   public SourceVersion getSupportedSourceVersion() {
-       return SourceVersion.latest();
-   }
 }
--- a/test/tools/javac/processing/model/element/TestElement.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/element/TestElement.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug 6453386
  * @summary Test basic properties of javax.lang.element.Element
  * @author  Joseph D. Darcy
- * @build TestElement
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TestElement
  * @compile -processor TestElement -proc:only TestElement.java
  */
 
@@ -43,8 +44,7 @@
 /**
  * Test basic workings of javax.lang.element.Element
  */
-@SupportedAnnotationTypes("*")
-public class TestElement extends AbstractProcessor {
+public class TestElement extends JavacTestingAbstractProcessor {
     /**
      * For now, just check that constructors have a simple name of
      * "<init>".
@@ -66,9 +66,4 @@
         }
         return true;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
 }
--- a/test/tools/javac/processing/model/element/TestNames.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/element/TestNames.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug 6380016
  * @summary Test that the constraints guaranteed by the Filer and maintained
  * @author  Joseph D. Darcy
- * @build TestNames
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TestNames
  * @compile -processor TestNames -proc:only TestNames.java
  */
 
@@ -45,11 +46,8 @@
 /**
  * Basic tests of semantics of javax.lang.model.element.Name
  */
-@SupportedAnnotationTypes("*")
-public class TestNames extends AbstractProcessor {
+public class TestNames extends JavacTestingAbstractProcessor {
     private int round = 0;
-    private Filer filer;
-    private Elements eltUtils;
 
     String stringStringName = "java.lang.String";
     Name stringName = null;
@@ -106,16 +104,6 @@
         return true;
     }
 
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        filer    = processingEnv.getFiler();
-        eltUtils = processingEnv.getElementUtils();
-    }
-
     private static class Pseudonym implements Name {
         private String name;
 
--- a/test/tools/javac/processing/model/element/TestPackageElement.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/element/TestPackageElement.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug 6449798 6399404
  * @summary Test basic workings of PackageElement
  * @author  Joseph D. Darcy
- * @build TestPackageElement
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TestPackageElement
  * @compile -processor TestPackageElement -proc:only TestPackageElement.java
  */
 
@@ -43,11 +44,7 @@
 /**
  * Test basic workings of PackageElement.
  */
-@SupportedAnnotationTypes("*")
-public class TestPackageElement extends AbstractProcessor {
-    private Filer filer;
-    private Elements eltUtils;
-
+public class TestPackageElement extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
         if (!roundEnv.processingOver()) {
@@ -71,15 +68,4 @@
         }
         return true;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        filer    = processingEnv.getFiler();
-        eltUtils = processingEnv.getElementUtils();
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/element/TestResourceElement.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,91 @@
+/*
+ * 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 6967842
+ * @summary Element not returned from tree API for ARM resource variables.
+ * @author A. Sundararajan
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TestResourceElement
+ * @compile -processor TestResourceElement -proc:only TestResourceElement.java
+ */
+
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import java.util.*;
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+
+public class TestResourceElement extends JavacTestingAbstractProcessor implements AutoCloseable {
+    public boolean process(Set<? extends TypeElement> annotations,
+                          RoundEnvironment roundEnv) {
+       if (!roundEnv.processingOver()) {
+           Trees trees = Trees.instance(processingEnv);
+
+           for(Element rootElement : roundEnv.getRootElements()) {
+               TreePath treePath = trees.getPath(rootElement);
+
+               VariableScanner varScanner =  new VariableScanner(trees);
+               varScanner.scan(trees.getTree(rootElement),
+                        treePath.getCompilationUnit());
+               if (varScanner.getTrvElement() == null) {
+                   throw new AssertionError("Element is null for 'trv'");
+               }
+           }
+       }
+       return true;
+    }
+
+    @Override
+    public void close() {}
+
+    private void test1() {
+        // The resource variable "trv"'s Element is checked.
+        // Do not change the name of the variable.
+        try(TestResourceElement trv = this) {}
+    }
+
+    class VariableScanner extends TreeScanner<Void, CompilationUnitTree> {
+       private Trees trees;
+       private Element trvElement;
+
+       public VariableScanner(Trees trees) {
+           super();
+           this.trees = trees;
+       }
+       @Override
+       public Void visitVariable(VariableTree node, CompilationUnitTree cu) {
+           // if this is "trv", get it's element.
+           if (node.getName().contentEquals("trv")) {
+               trvElement = trees.getElement(trees.getPath(cu, node));
+           }
+           return super.visitVariable(node, cu);
+       }
+
+       Element getTrvElement() {
+           return trvElement;
+       }
+   }
+}
--- a/test/tools/javac/processing/model/element/TestResourceVariable.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/element/TestResourceVariable.java	Wed Nov 10 19:07:04 2010 +0000
@@ -23,11 +23,12 @@
 
 /*
  * @test
- * @bug  6911256 6964740
+ * @bug  6911256 6964740 6967842
  * @summary Test that the resource variable kind is appropriately set
  * @author  Joseph D. Darcy
- * @build TestResourceVariable
- * @compile/fail -processor TestResourceVariable -proc:only TestResourceVariable.java
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TestResourceVariable
+ * @compile -processor TestResourceVariable -proc:only TestResourceVariable.java
  */
 
 // Bug should be filed for this misbehavior
@@ -48,8 +49,7 @@
  * resource of an ARM block and verify their kind tags are set
  * appropriately.
  */
-@SupportedAnnotationTypes("*")
-public class TestResourceVariable extends AbstractProcessor implements AutoCloseable {
+public class TestResourceVariable extends JavacTestingAbstractProcessor implements AutoCloseable {
     int resourceVariableCount = 0;
 
     public boolean process(Set<? extends TypeElement> annotations,
@@ -105,9 +105,4 @@
            return super.visitVariable(node, cu);
        }
    }
-
-   @Override
-   public SourceVersion getSupportedSourceVersion() {
-       return SourceVersion.latest();
-   }
 }
--- a/test/tools/javac/processing/model/element/TypeParamBounds.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/element/TypeParamBounds.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug     6423972
  * @summary Tests TypeParameter.getBounds.
  * @author  Scott Seligman
- * @build   TypeParamBounds
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TypeParamBounds
  * @compile -processor TypeParamBounds -proc:only TypeParamBounds.java
  */
 
@@ -40,18 +41,7 @@
 import javax.lang.model.type.*;
 import javax.lang.model.util.*;
 
-@SupportedAnnotationTypes("*")
-public class TypeParamBounds extends AbstractProcessor {
-
-    Elements elements;
-    Types types;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        elements = penv.getElementUtils();
-        types = penv.getTypeUtils();
-    }
-
+public class TypeParamBounds extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annoTypes,
                            RoundEnvironment round) {
         if (!round.processingOver())
@@ -59,11 +49,6 @@
         return true;
     }
 
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     private void doit(Set<? extends TypeElement> annoTypes,
                       RoundEnvironment round) {
         TypeElement gen = elements.getTypeElement("TypeParamBounds.Gen");
@@ -91,7 +76,6 @@
 
 
     // Fodder for the processor
-
     static class Gen<T, U extends Object, V extends Number, W extends U,
                      X extends Runnable, Y extends CharSequence & Runnable,
                      Z extends Object & Runnable> {
--- a/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/type/MirroredTypeEx/OverEager.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug     6362178
  * @summary MirroredType[s]Exception shouldn't be created too eagerly
  * @author  Scott Seligman
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile -g OverEager.java
  * @compile -processor OverEager -proc:only OverEager.java
  */
@@ -40,17 +42,7 @@
 
 @SupportedAnnotationTypes("IAm")
 @IAm(OverEager.class)
-public class OverEager extends AbstractProcessor {
-
-    Elements elements;
-    Types types;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        elements = penv.getElementUtils();
-        types =  penv.getTypeUtils();
-    }
-
+public class OverEager extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annoTypes,
                            RoundEnvironment round) {
         if (!round.processingOver())
@@ -58,11 +50,6 @@
         return true;
     }
 
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     private void doit(Set<? extends TypeElement> annoTypes,
                       RoundEnvironment round) {
         for (TypeElement t : typesIn(round.getRootElements())) {
--- a/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/type/MirroredTypeEx/Plurality.java	Wed Nov 10 19:07:04 2010 +0000
@@ -25,6 +25,8 @@
  * @test
  * @bug     6519115
  * @summary Verify MirroredTypeException vs MirroredTypesException is thrown
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile Plurality.java
  * @compile -processor Plurality -proc:only Plurality.java
  * @author  Joseph D. Darcy
@@ -38,25 +40,13 @@
 import javax.lang.model.type.*;
 import javax.lang.model.util.*;
 
-@SupportedAnnotationTypes("*")
 @P0
 @P1
 @P2
 @S1
-public class Plurality extends AbstractProcessor {
+public class Plurality extends JavacTestingAbstractProcessor {
     private boolean executed = false;
 
-    Elements elements;
-    Types types;
-
-    @Override
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        elements = penv.getElementUtils();
-        types =  penv.getTypeUtils();
-    }
-
-
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
         if (!roundEnv.processingOver()) {
@@ -164,11 +154,6 @@
                                            toStringName);
         }
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
 
 @Retention(RetentionPolicy.RUNTIME)
--- a/test/tools/javac/processing/model/type/NoTypes.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/type/NoTypes.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug     6418666 6423973 6453386
  * @summary Test the NoTypes: VOID, PACKAGE, NONE
  * @author  Scott Seligman
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile -g NoTypes.java
  * @compile -processor NoTypes -proc:only NoTypes.java
  */
@@ -39,18 +41,7 @@
 
 import static javax.lang.model.type.TypeKind.*;
 
-@SupportedAnnotationTypes("*")
-public class NoTypes extends AbstractProcessor {
-
-    Elements elements;
-    Types types;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        elements = penv.getElementUtils();
-        types =  penv.getTypeUtils();
-    }
-
+public class NoTypes extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annoTypes,
                            RoundEnvironment round) {
         if (!round.processingOver())
@@ -58,11 +49,6 @@
         return true;
     }
 
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     private void doit(Set<? extends TypeElement> annoTypes,
                       RoundEnvironment round) {
 
--- a/test/tools/javac/processing/model/util/BinaryName.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/BinaryName.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug     6346251
  * @summary Test Elements.getBinaryName
  * @author  Scott Seligman
- * @build   BinaryName
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor BinaryName
  * @compile -processor BinaryName -proc:only BinaryName.java
  */
 
@@ -38,17 +39,8 @@
 
 import static javax.lang.model.util.ElementFilter.typesIn;
 
-@SupportedAnnotationTypes("*")
 @HelloIm("BinaryName")
-public class BinaryName extends AbstractProcessor {
-
-    Elements elements;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        elements = penv.getElementUtils();
-    }
-
+public class BinaryName extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> tes,
                            RoundEnvironment round) {
         if (round.processingOver()) return true;
--- a/test/tools/javac/processing/model/util/GetTypeElemBadArg.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/GetTypeElemBadArg.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug     6346506 6408241
  * @summary getTypeElement should tolerate a type that can't be found
  * @author  Scott Seligman
- * @build   GetTypeElemBadArg
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor GetTypeElemBadArg
  * @compile -processor GetTypeElemBadArg -proc:only GetTypeElemBadArg.java
  */
 
@@ -37,16 +38,7 @@
 import javax.lang.model.type.*;
 import javax.lang.model.util.*;
 
-@SupportedAnnotationTypes("*")
-public class GetTypeElemBadArg extends AbstractProcessor {
-
-    Elements elements;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        elements = penv.getElementUtils();
-    }
-
+public class GetTypeElemBadArg extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> tes,
                            RoundEnvironment round) {
         if (round.processingOver()) return true;
@@ -63,12 +55,6 @@
         return true;
     }
 
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     private static void tellAbout(TypeElement t) {
         System.out.println(t);
         System.out.println(t.getClass());
--- a/test/tools/javac/processing/model/util/NoSupers.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/NoSupers.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug     6346453
  * @summary directSupertypes should return empty list if arg has no supertypes
  * @author  Scott Seligman
- * @build   NoSupers
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor NoSupers
  * @compile -processor NoSupers -proc:only NoSupers.java
  */
 
@@ -36,16 +37,7 @@
 import javax.lang.model.type.*;
 import javax.lang.model.util.*;
 
-@SupportedAnnotationTypes("*")
-public class NoSupers extends AbstractProcessor {
-
-    Types types;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        types = penv.getTypeUtils();
-    }
-
+public class NoSupers extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> tes,
                            RoundEnvironment round) {
         if (round.processingOver()) return true;
--- a/test/tools/javac/processing/model/util/OverridesSpecEx.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/OverridesSpecEx.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug     6453386
  * @summary Verify that example code in Elements.overrides works as spec'ed.
  * @author  Scott Seligman
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile -g OverridesSpecEx.java
  * @compile -processor OverridesSpecEx -proc:only OverridesSpecEx.java
  */
@@ -39,19 +41,7 @@
 
 import static javax.lang.model.util.ElementFilter.*;
 
-
-@SupportedAnnotationTypes("*")
-public class OverridesSpecEx extends AbstractProcessor {
-
-    Elements elements;
-    Types types;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        elements = penv.getElementUtils();
-        types =  penv.getTypeUtils();
-    }
-
+public class OverridesSpecEx extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annoTypes,
                            RoundEnvironment round) {
         if (!round.processingOver())
@@ -59,11 +49,6 @@
         return true;
     }
 
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     private void doit(Set<? extends TypeElement> annoTypes,
                       RoundEnvironment round) {
         TypeElement string = elements.getTypeElement("java.lang.String");
@@ -113,9 +98,7 @@
             throw new AssertionError("Bogus result");
     }
 
-
     // Fodder for the processor
-
     class A {
         public void m() {}
     }
--- a/test/tools/javac/processing/model/util/TypesBadArg.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/TypesBadArg.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug     6345812
  * @summary Validate argument kinds in Types utilities
  * @author  Scott Seligman
- * @build   TypesBadArg
+ * @library ../../../lib
+ * @build   JavacTestingAbstractProcessor TypesBadArg
  * @compile -processor TypesBadArg -proc:only TypesBadArg.java
  */
 
@@ -36,15 +37,9 @@
 import javax.lang.model.type.*;
 import javax.lang.model.util.*;
 
-@SupportedAnnotationTypes("*")
-public class TypesBadArg extends AbstractProcessor {
-
+public class TypesBadArg extends JavacTestingAbstractProcessor {
     boolean success = true;
 
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-    }
-
     public boolean process(Set<? extends TypeElement> tes,
                            RoundEnvironment round) {
         if (round.processingOver()) return true;
--- a/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/deprecation/TestDeprecation.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug 6392818
  * @summary Tests Elements.isDeprecated(Element)
  * @author  Joseph D. Darcy
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile TestDeprecation.java
  * @compile -processor TestDeprecation -proc:only Dep1.java
  * @compile Dep1.java
@@ -47,8 +49,7 @@
  * getElementsAnnotatedWith is consistent with the expected results
  * stored in an AnnotatedElementInfo annotation.
  */
-@SupportedAnnotationTypes("*")
-public class TestDeprecation extends AbstractProcessor {
+public class TestDeprecation extends JavacTestingAbstractProcessor {
 
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
@@ -98,9 +99,4 @@
             return failure;
         }
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/directSupersOfErr/DirectSupersOfErr.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug     6346973
  * @summary directSupertypes(t) should not return t
  * @author  Scott Seligman
- * @build   DirectSupersOfErr
+ * @library ../../../../lib
+ * @build   JavacTestingAbstractProcessor DirectSupersOfErr
  * @compile -processor DirectSupersOfErr -proc:only C1.java
  */
 
@@ -37,16 +38,7 @@
 import javax.lang.model.util.*;
 import static javax.lang.model.util.ElementFilter.*;
 
-@SupportedAnnotationTypes("*")
-public class DirectSupersOfErr extends AbstractProcessor {
-
-    Types types;
-
-    public void init(ProcessingEnvironment penv) {
-        super.init(penv);
-        types = penv.getTypeUtils();
-    }
-
+public class DirectSupersOfErr extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> tes,
                            RoundEnvironment round) {
         if (round.processingOver()) return true;
--- a/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/elements/TestGetConstantExpression.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,8 @@
  * @bug 6471577 6517779
  * @summary Test Elements.getConstantExpression
  * @author  Joseph D. Darcy
- * @build TestGetConstantExpression
+ * @library ../../../../lib
+ * @build   JavacTestingAbstractProcessor TestGetConstantExpression
  * @compile -processor TestGetConstantExpression Foo.java
  */
 
@@ -44,10 +45,7 @@
 /**
  * Test basic workings of Elements.getConstantExpression.
  */
-@SupportedAnnotationTypes("*")
-public class TestGetConstantExpression extends AbstractProcessor {
-    private Elements eltUtils;
-    private Filer filer;
+public class TestGetConstantExpression extends JavacTestingAbstractProcessor {
     private int round = 1;
 
     /**
@@ -130,14 +128,4 @@
             return 0;
         }
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        eltUtils = processingEnv.getElementUtils();
-        filer    = processingEnv.getFiler();
-    }
 }
--- a/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/elements/TestGetPackageOf.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,7 +26,8 @@
  * @bug 6453386
  * @summary Test Elements.getPackageOf
  * @author  Joseph D. Darcy
- * @build TestGetPackageOf
+ * @library ../../../../lib
+ * @build   JavacTestingAbstractProcessor TestGetPackageOf
  * @compile -processor TestGetPackageOf -proc:only TestGetPackageOf.java
  */
 
@@ -43,10 +44,7 @@
 /**
  * Test basic workings of Elements.getPackageOf
  */
-@SupportedAnnotationTypes("*")
-public class TestGetPackageOf extends AbstractProcessor {
-    private Elements eltUtils;
-
+public class TestGetPackageOf extends JavacTestingAbstractProcessor {
     /**
      * Check expected behavior on classes and packages.
      */
@@ -69,13 +67,4 @@
         }
         return true;
     }
-
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
-    public void init(ProcessingEnvironment processingEnv) {
-        super.init(processingEnv);
-        eltUtils = processingEnv.getElementUtils();
-    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/util/elements/doccomments/TestDocComments.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,310 @@
+/*
+ * 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 6877202 6986246
+ * @summary Elements.getDocComment() is not getting JavaDocComments
+ */
+
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.lang.model.util.*;
+import javax.tools.*;
+
+/*
+ * For a mixture of pre-existing and generated source files, ensure that we can
+ * get the doc comments.
+ * The test uses both a standard ElementScanner to find all the elements being
+ * processed, and a TreeScanner to find all the local and anonymous inner classes
+ * as well.
+ * And, because the relevant code paths in the compiler are different for
+ * command line and JSR 199 invocation, the test covers both ways of invoking the
+ * compiler.
+ */
+
+@SupportedOptions("scan")
+@SupportedAnnotationTypes("*")
+public class TestDocComments extends AbstractProcessor {
+    enum CompileKind { API, CMD };
+    enum ScanKind { TREE, ELEMENT };
+
+    // ----- Main test driver: invoke compiler for the various test cases ------
+
+    public static void main(String... args) throws Exception {
+        for (CompileKind ck: CompileKind.values()) {
+            for (ScanKind sk: ScanKind.values()) {
+                try {
+                    test(ck, sk);
+                } catch (IOException e) {
+                    error(e.toString());
+                }
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    static void test(CompileKind ck, ScanKind sk) throws IOException {
+        String testClasses = System.getProperty("test.classes");
+        String testSrc = System.getProperty("test.src");
+        File testDir = new File("test." + ck + "." + sk);
+        testDir.mkdirs();
+        String[] opts = {
+            "-d", testDir.getPath(),
+            "-implicit:none",
+            "-processor", TestDocComments.class.getName(),
+            "-processorpath", testClasses,
+            //"-XprintRounds",
+            "-Ascan=" + sk
+        };
+        File[] files = {
+            new File(testSrc, "a/First.java")
+        };
+
+        if (ck == CompileKind.API)
+            test_javac_api(opts, files);
+        else
+            test_javac_cmd(opts, files);
+    }
+
+    static void test_javac_api(String[] opts, File[] files) throws IOException {
+        System.err.println("test javac api: " + Arrays.asList(opts) + " " + Arrays.asList(files));
+        DiagnosticListener<JavaFileObject> dl = new DiagnosticListener<JavaFileObject>() {
+            public void report(Diagnostic diagnostic) {
+                error(diagnostic.toString());
+            }
+        };
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+        Iterable<? extends JavaFileObject> units = fm.getJavaFileObjects(files);
+        JavacTask t = (JavacTask) c.getTask(null, fm, dl, Arrays.asList(opts), null, units);
+        t.parse();
+        t.analyze();
+    }
+
+    static void test_javac_cmd(String[] opts, File[] files) {
+        System.err.println("test javac cmd: " + Arrays.asList(opts) + " " + Arrays.asList(files));
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        List<String> args = new ArrayList<String>(Arrays.asList(opts));
+        for (File f: files)
+            args.add(f.getPath());
+        int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw);
+        pw.close();
+        String out = sw.toString();
+        if (out.length() > 0)
+            System.err.println(out);
+        if (rc > 0)
+            error("Compilation failed: rc=" + rc);
+    }
+
+    static void error(String msg) {
+        System.err.println(msg);
+        errors++;
+        //throw new Error(msg);
+    }
+
+    static int errors;
+
+    // ----- Annotation processor: scan for elements and check doc comments ----
+
+    Map<String,String> options;
+    Filer filer;
+    Messager messager;
+    Elements elements;
+    Trees trees;
+    ScanKind skind;
+
+    int round = 0;
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        options = pEnv.getOptions();
+        filer = pEnv.getFiler();
+        messager = pEnv.getMessager();
+        elements = pEnv.getElementUtils();
+        trees = Trees.instance(processingEnv);
+        skind = ScanKind.valueOf(options.get("scan"));
+    }
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+
+        // Scan elements using an appropriate scanner, and for each element found,
+        // call check(Element e) to verify the doc comment on that element
+        for (Element e: roundEnv.getRootElements()) {
+            System.err.println("scan " + skind + " " + e.getKind() + " " + e.getSimpleName());
+            if (skind == ScanKind.TREE) {
+                new TestTreeScanner().scan(trees.getPath(e), trees);
+            }  else
+                new TestElementScanner().scan(e);
+        }
+
+        // For a few rounds, generate new source files, so that we can check whether
+        // doc comments are correctly handled in subsequent processing rounds
+        final int MAX_ROUNDS = 3;
+        if (round <= MAX_ROUNDS) {
+            String pkg = "p";
+            String currClass = "Gen" + round;
+            String curr = pkg + "." + currClass;
+            String next = (round < MAX_ROUNDS) ? (pkg + ".Gen" + (round + 1)) : "z.Last";
+            StringBuilder text = new StringBuilder();
+            text.append("package ").append(pkg).append(";\n");
+            text.append("/** CLASS ").append(currClass).append(" */\n");
+            text.append("public class ").append(currClass).append(" {\n");
+            text.append("    /** CONSTRUCTOR <init> **/\n");
+            text.append("    ").append(currClass).append("() { }\n");
+            text.append("    /** FIELD x */\n");
+            text.append("    ").append(next).append(" x;\n");
+            text.append("    /** METHOD m */\n");
+            text.append("    void m() { }\n");
+            text.append("}\n");
+
+            try {
+                JavaFileObject fo = filer.createSourceFile(curr);
+                Writer out = fo.openWriter();
+                try {
+                    out.write(text.toString());
+                } finally {
+                    out.close();
+                }
+            } catch (IOException e) {
+                throw new Error(e);
+            }
+        }
+
+        return true;
+    }
+
+    /*
+     * Check that the doc comment on an element is as expected.
+     * This method is invoked for each element found by the scanners run by process.
+     */
+    void check(Element e) {
+        System.err.println("Checking " + e);
+
+        String dc = elements.getDocComment(e);
+        System.err.println("   found " + dc);
+
+        String expect = (e.getKind() + " " + e.getSimpleName()); // default
+
+        Name name = e.getSimpleName();
+        Element encl = e.getEnclosingElement();
+        Name enclName = encl.getSimpleName();
+        ElementKind enclKind = encl.getKind();
+        switch (e.getKind()) {
+            case PARAMETER:
+            case LOCAL_VARIABLE:
+                // doc comments not retained for these elements
+                expect = null;
+                break;
+
+            case CONSTRUCTOR:
+                if (enclName.length() == 0 || enclKind == ElementKind.ENUM) {
+                    // Enum constructor is synthetic
+                    expect = null;
+                }
+                break;
+
+            case METHOD:
+                if (enclKind == ElementKind.ENUM
+                        && (name.contentEquals("values") || name.contentEquals("valueOf"))) {
+                    // synthetic enum methods
+                    expect = null;
+                }
+                break;
+
+            case CLASS:
+                if (e.getSimpleName().length() == 0) {
+                    // anon inner class
+                    expect = null;
+                }
+                break;
+        }
+
+        System.err.println("  expect " + expect);
+
+        if (dc == null ? expect == null : dc.trim().equals(expect))
+            return;
+
+        if (dc == null)
+            messager.printMessage(Diagnostic.Kind.ERROR, "doc comment is null", e);
+        else {
+            messager.printMessage(Diagnostic.Kind.ERROR,
+                    "unexpected comment: \"" + dc + "\", expected \"" + expect + "\"", e);
+        }
+    }
+
+    // ----- Scanners to find elements -----------------------------------------
+
+    class TestElementScanner extends ElementScanner7<Void, Void> {
+        @Override
+        public Void visitExecutable(ExecutableElement e, Void _) {
+            check(e);
+            return super.visitExecutable(e, _);
+        }
+        @Override
+        public Void visitType(TypeElement e, Void _) {
+            check(e);
+            return super.visitType(e, _);
+        }
+        @Override
+        public Void visitVariable(VariableElement e, Void _) {
+            check(e);
+            return super.visitVariable(e, _);
+        }
+    }
+
+    class TestTreeScanner extends TreePathScanner<Void,Trees> {
+        @Override
+        public Void visitClass(ClassTree tree, Trees trees) {
+            check(trees.getElement(getCurrentPath()));
+            return super.visitClass(tree, trees);
+        }
+        @Override
+        public Void visitMethod(MethodTree tree, Trees trees) {
+            check(trees.getElement(getCurrentPath()));
+            return super.visitMethod(tree, trees);
+        }
+        @Override
+        public Void visitVariable(VariableTree tree, Trees trees) {
+            check(trees.getElement(getCurrentPath()));
+            return super.visitVariable(tree, trees);
+        }
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/util/elements/doccomments/a/First.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package a;
+
+/** CLASS First */
+public class First {
+    /** CONSTRUCTOR <init> */
+    First() { }
+
+    /** FIELD x */
+    p.Gen1 x;
+
+    /** METHOD m **/
+    void m(int i) {
+        /** CLASS Local */
+        class Local {
+            /** CONSTRUCTOR <init> */
+            Local() { }
+        }
+
+        Runnable r = new Runnable() {
+            /** METHOD run **/
+            public void run() { }
+        };
+
+    }
+
+    /** ENUM E */
+    enum E {
+        /** ENUM_CONSTANT e1 */
+        e1
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/model/util/elements/doccomments/z/Last.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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.
+ */
+
+package z;
+
+// This class should be read last, implicitly. Therefore it should not
+// be subject to anno processing. If it is, the lack of doc comments should
+// be detected and will flag an error.
+public class Last {
+}
--- a/test/tools/javac/processing/model/util/filter/TestIterables.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/model/util/filter/TestIterables.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -26,6 +26,8 @@
  * @bug 6406164
  * @summary Test that ElementFilter iterable methods behave properly.
  * @author  Joseph D. Darcy
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor
  * @compile TestIterables.java
  * @compile -processor TestIterables -proc:only Foo1.java
  * @compile Foo1.java
@@ -51,9 +53,8 @@
  * results.
  */
 @SupportedAnnotationTypes("ExpectedElementCounts")
-@ExpectedElementCounts(methods=3)
-public class TestIterables extends AbstractProcessor {
-
+@ExpectedElementCounts(methods=2)
+public class TestIterables extends JavacTestingAbstractProcessor {
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
         if (!roundEnv.processingOver()) {
@@ -118,10 +119,4 @@
 
         return count1;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/options/TestImplicitNone.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,109 @@
+/*
+ * 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 6935638
+ * @summary -implicit:none prevents compilation with annotation processing
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+
+
+@SupportedAnnotationTypes("*")
+public class TestImplicitNone extends AbstractProcessor {
+    public static void main(String... args) throws Exception {
+        new TestImplicitNone().run();
+    }
+
+    void run() throws Exception {
+        File classesDir = new File("tmp", "classes");
+        classesDir.mkdirs();
+        File test_java = new File(new File("tmp", "src"), "Test.java");
+        writeFile(test_java, "class Test { }");
+
+        // build up list of options and files to be compiled
+        List<String> opts = new ArrayList<String>();
+        List<File> files = new ArrayList<File>();
+
+        opts.add("-d");
+        opts.add(classesDir.getPath());
+        opts.add("-processorpath");
+        opts.add(System.getProperty("test.classes"));
+        opts.add("-implicit:none");
+        opts.add("-processor");
+        opts.add(TestImplicitNone.class.getName());
+        files.add(test_java);
+
+        compile(opts, files);
+
+        File test_class = new File(classesDir, "Test.class");
+        if (!test_class.exists())
+            throw new Exception("Test.class not generated");
+    }
+
+    /** Compile files with options provided. */
+    void compile(List<String> opts, List<File> files) throws Exception {
+        System.err.println("javac: " + opts + " " + files);
+        List<String> args = new ArrayList<String>();
+        args.addAll(opts);
+        for (File f: files)
+            args.add(f.getPath());
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), pw);
+        pw.flush();
+        if (sw.getBuffer().length() > 0)
+            System.err.println(sw.toString());
+        if (rc != 0)
+            throw new Exception("compilation failed: rc=" + rc);
+    }
+
+    /** Write a file with a given body. */
+    void writeFile(File f, String body) throws Exception {
+        if (f.getParentFile() != null)
+            f.getParentFile().mkdirs();
+        Writer out = new FileWriter(f);
+        try {
+            out.write(body);
+        } finally {
+            out.close();
+        }
+    }
+
+    //----- annotation processor methods -----
+
+    public boolean process(Set<? extends TypeElement> annotations,
+                         RoundEnvironment roundEnv) {
+        return true;
+    }
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/options/Xprint.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,42 @@
+/*
+ * 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug     6266828
+ * @summary JSR 269: Java Language Model API
+ * @author  Peter von der Ah\u00e9
+ */
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
+
+public class Xprint {
+    public static void main(String[] args) {
+        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        javac.run(System.in, null, null,
+                  "-Xprint",
+                  "com.sun.tools.javac.code.Types",
+                  "com.sun.tools.javac.parser.Parser",
+                  "java.util.EnumSet");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/options/XprintDocComments.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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 6861094
+ * @summary javac -Xprint <file> does not print comments
+ * @compile/ref=XprintDocComments.out -Xprint  XprintDocComments.java
+ */
+
+/**
+ * CLASS XprintDocComments
+ */
+class XPrintDocComments {
+    /**
+     * FIELD i;
+     */
+    int i;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/processing/options/XprintDocComments.out	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,12 @@
+
+/**
+ * CLASS XprintDocComments
+ */
+class XPrintDocComments {
+
+  XPrintDocComments();
+  /**
+   * FIELD i;
+   */
+  int i;
+}
--- a/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/warnings/TestSourceVersionWarnings.java	Wed Nov 10 19:07:04 2010 +0000
@@ -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
@@ -50,7 +50,8 @@
 
 /**
  * This processor returns the supported source level as indicated by
- * the "SourceLevel" option.
+ * the "SourceLevel" option; therefore, don't use
+ * JavacTestingAbstractProcessor which returns the latest source level.
  */
 @SupportedAnnotationTypes("*")
 @SupportedOptions("SourceVersion")
--- a/test/tools/javac/processing/werror/WError1.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/werror/WError1.java	Wed Nov 10 19:07:04 2010 +0000
@@ -24,6 +24,8 @@
 /*
  * @test 6403456
  * @summary -Werror should work with annotation processing
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile WError1.java
  * @compile -proc:only -processor WError1 WError1.java
  * @compile/fail/ref=WError1.out -XDrawDiagnostics -Werror -proc:only -processor WError1 WError1.java
@@ -36,22 +38,15 @@
 import javax.lang.model.element.*;
 import javax.tools.*;
 
-@SupportedAnnotationTypes("*")
-public class WError1 extends AbstractProcessor {
+public class WError1 extends JavacTestingAbstractProcessor {
     @Override
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
-        Messager messager = processingEnv.getMessager();
         if (++round == 1) {
             messager.printMessage(Diagnostic.Kind.WARNING, "round 1");
         }
         return true;
     }
 
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     int round = 0;
 }
--- a/test/tools/javac/processing/werror/WErrorGen.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/werror/WErrorGen.java	Wed Nov 10 19:07:04 2010 +0000
@@ -24,6 +24,8 @@
 /*
  * @test 6403456
  * @summary -Werror should work with annotation processing
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile WErrorGen.java
  * @compile -proc:only -processor WErrorGen WErrorGen.java
  * @compile/fail/ref=WErrorGen.out -XDrawDiagnostics -Werror -Xlint:rawtypes -processor WErrorGen WErrorGen.java
@@ -36,12 +38,10 @@
 import javax.lang.model.element.*;
 import javax.tools.*;
 
-@SupportedAnnotationTypes("*")
-public class WErrorGen extends AbstractProcessor {
+public class WErrorGen extends JavacTestingAbstractProcessor {
     @Override
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
-        Filer filer = processingEnv.getFiler();
         if (++round == 1) {
             try {
                 JavaFileObject fo = filer.createSourceFile("Gen");
@@ -54,10 +54,5 @@
         return true;
     }
 
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
-
     int round = 0;
 }
--- a/test/tools/javac/processing/werror/WErrorLast.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/processing/werror/WErrorLast.java	Wed Nov 10 19:07:04 2010 +0000
@@ -24,6 +24,8 @@
 /*
  * @test 6403456
  * @summary -Werror should work with annotation processing
+ * @library ../../lib
+ * @build   JavacTestingAbstractProcessor
  * @compile WErrorLast.java
  * @compile -proc:only -processor WErrorLast WErrorLast.java
  * @compile/fail/ref=WErrorLast.out -XDrawDiagnostics -Werror -proc:only -processor WErrorLast WErrorLast.java
@@ -36,20 +38,13 @@
 import javax.lang.model.element.*;
 import javax.tools.*;
 
-@SupportedAnnotationTypes("*")
-public class WErrorLast extends AbstractProcessor {
+public class WErrorLast extends JavacTestingAbstractProcessor {
     @Override
     public boolean process(Set<? extends TypeElement> annotations,
                            RoundEnvironment roundEnv) {
-        Messager messager = processingEnv.getMessager();
         if (roundEnv.processingOver()) {
             messager.printMessage(Diagnostic.Kind.WARNING, "last round");
         }
         return true;
     }
-
-    @Override
-    public SourceVersion getSupportedSourceVersion() {
-        return SourceVersion.latest();
-    }
 }
--- a/test/tools/javac/quid/MakeNegTests.sh	Tue Sep 14 11:37:19 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 6746458
-# @summary Verify correct rejection of illegal quoted identifiers.
-# @run shell MakeNegTests.sh
-
-default_template=QuotedIdent.java
-# the rest of this file is a generic "//BAD"-line tester
-
-: ${TESTSRC=.} ${TESTCLASSES=.}
-javac="${TESTJAVA+${TESTJAVA}/bin/}javac"
-
-verbose=false quiet=false
-
-main() {
-  case "${@-}" in
-  *.java*)
-    for template in "$@"; do
-      expand_and_test "$template"
-    done;;
-  *) expand_and_test "${TESTSRC}/$default_template";;
-  esac
-}
-
-expand_and_test() {
-  template=$1
-  expand "$@"
-  testneg "$@"
-}
-
-expand() {
-  template=$1
-  badlines=` grep -n < "$template" '//BAD' `
-  badcount=` echo "$badlines" | wc -l `
-  [ $badcount -gt 0 ] || { echo "No negative test cases in $template"; exit 1; }
-  $quiet || echo "Expanding $badcount negative test cases from $template:"
-  $quiet || echo "$badlines"
-  badnums=` echo "$badlines" | sed 's/:.*//' `
-  casestem=` getcasestem "$template" `
-  tclassname=` basename "$template" .java `
-  rm "$casestem"*.java
-  for badnum in $badnums; do
-    casefile="$casestem"${badnum}.java
-    cclassname=` basename "$casefile" .java `
-    sed < "$template" > "$casefile" "
-      s|@compile|@compile/fail|
-      / @[a-z]/s|@|##|
-      ${badnum}s:^ *[/*]*:    :
-      s/${tclassname}/${cclassname}/g
-    "
-    $verbose && diff -u "$template" "$casefile"
-  done
-}
-
-getcasestem() {
-  echo `basename $1` | sed 's/.*\///;s/\.java$//;s/_BAD[0-9]*$//;s/$/_BAD/'
-}
-
-testneg() {
-  template=$1
-  for casefile in ` getcasestem "$template" `*.java; do
-    $quiet || echo -------- $javac "$casefile"
-    $javac "$casefile" > "$casefile".errlog 2>&1 && {
-      echo "*** Compilation unexpectedly succeeded:  $casefile"
-      exit 1
-    }
-    $quiet || echo "Compilation failed as expected"
-    $quiet || head ` $verbose || echo -3 ` < "$casefile".errlog
-    rm "$casefile".errlog
-  done
-}
-
-main "$@"
--- a/test/tools/javac/quid/QuotedIdent.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/quid/QuotedIdent.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
  *      (The filename, directory name, or volume label syntax is incorrect)
  *
  * @library ..
+ * @compile -source 7 -target 7 -XDinvokedynamic QuotedIdent.java
  * @run main quid.QuotedIdent
  */
 
@@ -119,7 +120,7 @@
         s = #"int".class.getName();
         check(31, s, QuotedIdent.class.getName()+"$int");
 
-        Class x86 = Class.forName(QuotedIdent.class.getName()+"$*86");
+        Class<?> x86 = Class.forName(QuotedIdent.class.getName()+"$*86");
         if (x86 != #"*86".class)
             check(32, "reflected "+x86, "static "+#"*86".class);
 
--- a/test/tools/javac/quid/QuotedIdent2.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javac/quid/QuotedIdent2.java	Wed Nov 10 19:07:04 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,7 @@
  *      (The filename, directory name, or volume label syntax is incorrect)
  *
  * @library ..
+ * @compile -source 7 -target 7 -XDinvokedynamic QuotedIdent.java
  * @run main quid.QuotedIdent2
  */
 /*
@@ -72,7 +73,7 @@
         s = QuotedIdent.#"int".class.getName();
         check(31, s, QuotedIdent.class.getName()+"$int");
 
-        Class x86 = Class.forName(QuotedIdent.class.getName()+"$*86");
+        Class<?> x86 = Class.forName(QuotedIdent.class.getName()+"$*86");
         if (x86 != #"*86".class)
             check(32, "reflected "+x86, "static "+#"*86".class);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/tree/AbstractTreeScannerTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,294 @@
+/*
+ * 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.*;
+import java.lang.reflect.*;
+import java.util.*;
+import javax.tools.*;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.util.List;
+
+public abstract class AbstractTreeScannerTest {
+
+    /**
+     * Run the program. A base directory can be provided for file arguments.
+     * In jtreg mode, the -r option can be given to change the default base
+     * directory to the test root directory. For other options, see usage().
+     * @param baseDir base directory for any file arguments.
+     * @param args command line args
+     * @return true if successful or in gui mode
+     */
+    boolean run(File baseDir, String... args) {
+        if (args.length == 0) {
+            usage(System.out);
+            return true;
+        }
+
+        ArrayList<File> files = new ArrayList<File>();
+        for (int i = 0; i < args.length; i++) {
+            String arg = args[i];
+            if (arg.equals("-q"))
+                quiet = true;
+            else if (arg.equals("-v"))
+                verbose = true;
+            else if (arg.equals("-r")) {
+                File d = baseDir;
+                while (!new File(d, "TEST.ROOT").exists()) {
+                    d = d.getParentFile();
+                    if (d == null)
+                        throw new Error("cannot find TEST.ROOT");
+                }
+                baseDir = d;
+            }
+            else if (arg.startsWith("-"))
+                throw new Error("unknown option: " + arg);
+            else {
+                while (i < args.length)
+                    files.add(new File(baseDir, args[i++]));
+            }
+        }
+
+        for (File file: files) {
+            if (file.exists())
+                test(file);
+            else
+                error("File not found: " + file);
+        }
+
+        if (fileCount != 1)
+            System.err.println(fileCount + " files read");
+        System.err.println(treeCount + " tree nodes compared");
+        if (errors > 0)
+            System.err.println(errors + " errors");
+
+        return (errors == 0);
+    }
+
+    /**
+     * Print command line help.
+     * @param out output stream
+     */
+    void usage(PrintStream out) {
+        out.println("Usage:");
+        out.println("  java " + getClass().getName() + " options... files...");
+        out.println("");
+        out.println("where options include:");
+        out.println("-q        Quiet: don't report on inapplicable files");
+        out.println("-v        Verbose: report on files as they are being read");
+        out.println("");
+        out.println("files may be directories or files");
+        out.println("directories will be scanned recursively");
+        out.println("non java files, or java files which cannot be parsed, will be ignored");
+        out.println("");
+    }
+
+    /**
+     * Test a file. If the file is a directory, it will be recursively scanned
+     * for java files.
+     * @param file the file or directory to test
+     */
+    void test(File file) {
+        if (file.isDirectory()) {
+            for (File f: file.listFiles()) {
+                test(f);
+            }
+            return;
+        }
+
+        if (file.isFile() && file.getName().endsWith(".java")) {
+            try {
+                if (verbose)
+                    System.err.println(file);
+                fileCount++;
+                treeCount += test(read(file));
+            } catch (ParseException e) {
+                if (!quiet) {
+                    error("Error parsing " + file + "\n" + e.getMessage());
+                }
+            } catch (IOException e) {
+                error("Error reading " + file + ": " + e);
+            }
+            return;
+        }
+
+        if (!quiet)
+            error("File " + file + " ignored");
+    }
+
+    abstract int test(JCCompilationUnit t);
+
+    /**
+     * Read a file.
+     * @param file the file to be read
+     * @return the tree for the content of the file
+     * @throws IOException if any IO errors occur
+     * @throws TreePosTest.ParseException if any errors occur while parsing the file
+     */
+    JCCompilationUnit read(File file) throws IOException, ParseException {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        Reporter r = new Reporter(pw);
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
+        JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
+        Iterable<? extends CompilationUnitTree> trees = task.parse();
+        pw.flush();
+        if (r.errors > 0)
+            throw new ParseException(sw.toString());
+        Iterator<? extends CompilationUnitTree> iter = trees.iterator();
+        if (!iter.hasNext())
+            throw new Error("no trees found");
+        JCCompilationUnit t = (JCCompilationUnit) iter.next();
+        if (iter.hasNext())
+            throw new Error("too many trees found");
+        return t;
+    }
+
+    /**
+     * Report an error. When the program is complete, the program will either
+     * exit or throw an Error if any errors have been reported.
+     * @param msg the error message
+     */
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    /**
+     * Report an error. When the program is complete, the program will either
+     * exit or throw an Error if any errors have been reported.
+     * @param msg the error message
+     */
+    void error(JavaFileObject file, String msg) {
+        System.err.println(file.getName() + ": " + msg);
+        errors++;
+    }
+
+    /**
+     *  Report an error for a specific tree node.
+     *  @param file the source file for the tree
+     *  @param t    the tree node
+     *  @param label an indication of the error
+     */
+    void error(JavaFileObject file, Tree tree, String msg) {
+        JCTree t = (JCTree) tree;
+        error(file.getName() + ":" + getLine(file, t) + ": " + msg + " " + trim(t, 64));
+    }
+
+    /**
+     * Get a trimmed string for a tree node, with normalized white space and limited length.
+     */
+    String trim(Tree tree, int len) {
+        JCTree t = (JCTree) tree;
+        String s = t.toString().replaceAll("\\s+", " ");
+        return (s.length() < len) ? s : s.substring(0, len);
+    }
+
+    /** Number of files that have been analyzed. */
+    int fileCount;
+    /** Number of trees that have been successfully compared. */
+    int treeCount;
+    /** Number of errors reported. */
+    int errors;
+    /** Flag: don't report irrelevant files. */
+    boolean quiet;
+    /** Flag: report files as they are processed. */
+    boolean verbose;
+
+
+    /**
+     * Thrown when errors are found parsing a java file.
+     */
+    private static class ParseException extends Exception {
+        ParseException(String msg) {
+            super(msg);
+        }
+    }
+
+    /**
+     * DiagnosticListener to report diagnostics and count any errors that occur.
+     */
+    private static class Reporter implements DiagnosticListener<JavaFileObject> {
+        Reporter(PrintWriter out) {
+            this.out = out;
+        }
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            out.println(diagnostic);
+            switch (diagnostic.getKind()) {
+                case ERROR:
+                    errors++;
+            }
+        }
+        int errors;
+        PrintWriter out;
+    }
+
+    /**
+     * Get the set of fields for a tree node that may contain child tree nodes.
+     * These are the fields that are subtypes of JCTree or List.
+     * The results are cached, based on the tree's tag.
+     */
+    Set<Field> getFields(JCTree tree) {
+        Set<Field> fields = map.get(tree.getTag());
+        if (fields == null) {
+            fields = new HashSet<Field>();
+            for (Field f: tree.getClass().getFields()) {
+                Class<?> fc = f.getType();
+                if (JCTree.class.isAssignableFrom(fc) || List.class.isAssignableFrom(fc))
+                    fields.add(f);
+            }
+            map.put(tree.getTag(), fields);
+        }
+        return fields;
+    }
+    // where
+    Map<Integer, Set<Field>> map = new HashMap<Integer,Set<Field>>();
+
+    /** Get the line number for the primary position for a tree.
+     * The code is intended to be simple, although not necessarily efficient.
+     * However, note that a file manager such as JavacFileManager is likely
+     * to cache the results of file.getCharContent, avoiding the need to read
+     * the bits from disk each time this method is called.
+     */
+    int getLine(JavaFileObject file, JCTree tree) {
+        try {
+            CharSequence cs = file.getCharContent(true);
+            int line = 1;
+            for (int i = 0; i < tree.pos; i++) {
+                if (cs.charAt(i) == '\n') // jtreg tests always use Unix line endings
+                    line++;
+            }
+            return line;
+        } catch (IOException e) {
+            return -1;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/tree/ClassTreeTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,102 @@
+/*
+ * 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 6570730
+ * @summary com.sun.source.tree.ModifiersTree.getFlags() should return class type
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+import com.sun.tools.javac.api.*;
+
+public class ClassTreeTest {
+    public static void main(String... args) throws Exception {
+        new ClassTreeTest().run();
+    }
+
+    void run() throws Exception {
+        JavacTool tool = JavacTool.create();
+        StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
+        List<String> opts = Collections.<String>emptyList();
+        File testSrc = new File(System.getProperty("test.src"));
+        File thisFile = new File(testSrc, ClassTreeTest.class.getSimpleName() + ".java");
+        Iterable<? extends JavaFileObject> fos = fm.getJavaFileObjects(thisFile);
+        JavacTask task = tool.getTask(null, fm, null, opts, null, fos);
+        for (CompilationUnitTree cu: task.parse()) {
+            check(cu, "CLASS", Tree.Kind.CLASS);
+            check(cu, "INTERFACE", Tree.Kind.INTERFACE);
+            check(cu, "ENUM", Tree.Kind.ENUM);
+            check(cu, "ANNOTATION_TYPE", Tree.Kind.ANNOTATION_TYPE);
+        }
+
+        int expected = 4;
+        if (checks != expected)
+            error("Unexpected number of checks performed; expected: " + expected + ", found: " + checks);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void check(CompilationUnitTree cu, String name, Tree.Kind k) {
+        checks++;
+
+        TreeScanner<ClassTree,String> s = new TreeScanner<ClassTree,String>() {
+            @Override
+            public ClassTree visitClass(ClassTree c, String name) {
+                if (c.getSimpleName().toString().equals(name))
+                    return c;
+                else
+                    return super.visitClass(c, name);
+            }
+
+            @Override
+            public ClassTree reduce(ClassTree t1, ClassTree t2) {
+                return (t1 != null ? t1 : t2);
+            }
+        };
+
+        ClassTree c = s.scan(cu, name);
+        if (c == null)
+            error("Can't find node named " + name);
+        else if (c.getKind() != k)
+            error("Unexpected kind for node named " + name + ": expected: " + k + ", found: " + c.getKind());
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int checks;
+    int errors;
+
+    class CLASS { }
+    interface INTERFACE { }
+    enum ENUM { }
+    @interface ANNOTATION_TYPE { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/tree/JavacTreeScannerTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,156 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * Utility and test program to check javac's internal TreeScanner class.
+ * The program can be run standalone, or as a jtreg test.  For info on
+ * command line args, run program with no args.
+ *
+ * <p>
+ * jtreg: Note that by using the -r switch in the test description below, this test
+ * will process all java files in the langtools/test directory, thus implicitly
+ * covering any new language features that may be tested in this test suite.
+ */
+
+/*
+ * @test
+ * @bug 6923080
+ * @summary TreeScanner.visitNewClass should scan tree.typeargs
+ * @build AbstractTreeScannerTest JavacTreeScannerTest
+ * @run main JavacTreeScannerTest -q -r .
+ */
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.util.*;
+import javax.tools.*;
+
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.TreeScanner;
+import com.sun.tools.javac.util.List;
+
+public class JavacTreeScannerTest extends AbstractTreeScannerTest {
+    /**
+     * Main entry point.
+     * If test.src is set, program runs in jtreg mode, and will throw an Error
+     * if any errors arise, otherwise System.exit will be used. In jtreg mode,
+     * the default base directory for file args is the value of ${test.src}.
+     * In jtreg mode, the -r option can be given to change the default base
+     * directory to the root test directory.
+     */
+    public static void main(String... args) {
+        String testSrc = System.getProperty("test.src");
+        File baseDir = (testSrc == null) ? null : new File(testSrc);
+        boolean ok = new JavacTreeScannerTest().run(baseDir, args);
+        if (!ok) {
+            if (testSrc != null)  // jtreg mode
+                throw new Error("failed");
+            else
+                System.exit(1);
+        }
+    }
+
+    int test(JCCompilationUnit tree) {
+        return new ScanTester().test(tree);
+    }
+
+    /**
+     * Main class for testing operation of tree scanner.
+     * The set of nodes found by the scanner are compared
+     * against the set of nodes found by reflection.
+     */
+    private class ScanTester extends TreeScanner {
+        /** Main entry method for the class. */
+        int test(JCCompilationUnit tree) {
+            sourcefile = tree.sourcefile;
+            found = new HashSet<JCTree>();
+            scan(tree);
+            expect = new HashSet<JCTree>();
+            reflectiveScan(tree);
+
+            if (found.equals(expect)) {
+                //System.err.println(sourcefile.getName() + ": trees compared OK");
+                return found.size();
+            }
+
+            error(sourcefile, "differences found");
+
+            if (found.size() != expect.size())
+                error("Size mismatch; found: " + found.size() + ", expected: " + expect.size());
+
+            Set<JCTree> missing = new HashSet<JCTree>();
+            missing.addAll(expect);
+            missing.removeAll(found);
+            for (JCTree t: missing)
+                error(sourcefile, t, "missing");
+
+            Set<JCTree> excess = new HashSet<JCTree>();
+            excess.addAll(found);
+            excess.removeAll(expect);
+            for (JCTree t: excess)
+                error(sourcefile, t, "unexpected");
+
+            return 0;
+        }
+
+        /** Record all tree nodes found by scanner. */
+        @Override
+        public void scan(JCTree tree) {
+            if (tree == null)
+                return;
+            //System.err.println("FOUND: " + tree.getTag() + " " + trim(tree, 64));
+            found.add(tree);
+            super.scan(tree);
+        }
+
+        /** record all tree nodes found by reflection. */
+        public void reflectiveScan(Object o) {
+            if (o == null)
+                return;
+            if (o instanceof JCTree) {
+                JCTree tree = (JCTree) o;
+                //System.err.println("EXPECT: " + tree.getTag() + " " + trim(tree, 64));
+                expect.add(tree);
+                for (Field f: getFields(tree)) {
+                    try {
+                        //System.err.println("FIELD: " + f.getName());
+                        reflectiveScan(f.get(tree));
+                    } catch (IllegalAccessException e) {
+                        error(e.toString());
+                    }
+                }
+            } else if (o instanceof List) {
+                List<?> list = (List<?>) o;
+                for (Object item: list)
+                    reflectiveScan(item);
+            } else
+                error("unexpected item: " + o);
+        }
+
+        JavaFileObject sourcefile;
+        Set<JCTree> found;
+        Set<JCTree> expect;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/tree/SourceTreeScannerTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,169 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * Utility and test program to check javac's internal TreeScanner class.
+ * The program can be run standalone, or as a jtreg test.  For info on
+ * command line args, run program with no args.
+ *
+ * <p>
+ * jtreg: Note that by using the -r switch in the test description below, this test
+ * will process all java files in the langtools/test directory, thus implicitly
+ * covering any new language features that may be tested in this test suite.
+ */
+
+/*
+ * @test
+ * @bug 6923080
+ * @summary TreeScanner.visitNewClass should scan tree.typeargs
+ * @build AbstractTreeScannerTest SourceTreeScannerTest
+ * @run main SourceTreeScannerTest -q -r .
+ */
+
+import java.io.*;
+import java.lang.reflect.*;
+import java.util.*;
+import javax.tools.*;
+
+import com.sun.source.tree.Tree;
+import com.sun.source.util.TreeScanner;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.TypeBoundKind;
+import com.sun.tools.javac.util.List;
+
+public class SourceTreeScannerTest extends AbstractTreeScannerTest {
+    /**
+     * Main entry point.
+     * If test.src is set, program runs in jtreg mode, and will throw an Error
+     * if any errors arise, otherwise System.exit will be used. In jtreg mode,
+     * the default base directory for file args is the value of ${test.src}.
+     * In jtreg mode, the -r option can be given to change the default base
+     * directory to the root test directory.
+     */
+    public static void main(String... args) {
+        String testSrc = System.getProperty("test.src");
+        File baseDir = (testSrc == null) ? null : new File(testSrc);
+        boolean ok = new SourceTreeScannerTest().run(baseDir, args);
+        if (!ok) {
+            if (testSrc != null)  // jtreg mode
+                throw new Error("failed");
+            else
+                System.exit(1);
+        }
+    }
+
+    int test(JCCompilationUnit tree) {
+        return new ScanTester().test(tree);
+    }
+
+    /**
+     * Main class for testing operation of tree scanner.
+     * The set of nodes found by the scanner are compared
+     * against the set of nodes found by reflection.
+     */
+    private class ScanTester extends TreeScanner<Void,Void> {
+        /** Main entry method for the class. */
+        int test(JCCompilationUnit tree) {
+            sourcefile = tree.sourcefile;
+            found = new HashSet<Tree>();
+            scan(tree, null);
+            expect = new HashSet<Tree>();
+            reflectiveScan(tree);
+
+            if (found.equals(expect)) {
+                //System.err.println(sourcefile.getName() + ": trees compared OK");
+                return found.size();
+            }
+
+            error(sourcefile.getName() + ": differences found");
+
+            if (found.size() != expect.size())
+                error("Size mismatch; found: " + found.size() + ", expected: " + expect.size());
+
+            Set<Tree> missing = new HashSet<Tree>();
+            missing.addAll(expect);
+            missing.removeAll(found);
+            for (Tree t: missing)
+                error(sourcefile, t, "missing");
+
+            Set<Tree> excess = new HashSet<Tree>();
+            excess.addAll(found);
+            excess.removeAll(expect);
+            for (Tree t: excess)
+                error(sourcefile, t, "unexpected");
+
+            return 0;
+        }
+
+        /** Record all tree nodes found by scanner. */
+        @Override
+        public Void scan(Tree tree, Void ignore) {
+            if (tree == null)
+                return null;
+            //System.err.println("FOUND: " + tree.getKind() + " " + trim(tree, 64));
+            found.add(tree);
+            return super.scan(tree, ignore);
+        }
+
+        /** record all tree nodes found by reflection. */
+        public void reflectiveScan(Object o) {
+            if (o == null)
+                return;
+            if (o instanceof JCTree) {
+                JCTree tree = (JCTree) o;
+                //System.err.println("EXPECT: " + tree.getKind() + " " + trim(tree, 64));
+                expect.add(tree);
+                for (Field f: getFields(tree)) {
+                    if (TypeBoundKind.class.isAssignableFrom(f.getType())) {
+                        // not part of public API
+                        continue;
+                    }
+                    if (JCTree.JCNewArray.class.isAssignableFrom(tree.getClass())
+                            && (f.getName().equals("annotations")
+                                || f.getName().equals("dimAnnotations"))) {
+                        // these fields are incorrectly missing from the public API
+                        // (CR 6983297)
+                        continue;
+                    }
+                    try {
+                        //System.err.println("FIELD: " + f.getName());
+                        reflectiveScan(f.get(tree));
+                    } catch (IllegalAccessException e) {
+                        error(e.toString());
+                    }
+                }
+            } else if (o instanceof List) {
+                List<?> list = (List<?>) o;
+                for (Object item: list)
+                    reflectiveScan(item);
+            } else
+                error("unexpected item: " + o);
+        }
+
+        JavaFileObject sourcefile;
+        Set<Tree> found;
+        Set<Tree> expect;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/tree/TreeKindTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,132 @@
+/*
+ * 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 TreeKindTest{
+    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 INTERFACE:
+            case ANNOTATION_TYPE:
+            case ENUM:
+            case CLASS:
+                ok = ok & verify(k, i, i == ClassTree.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;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/tree/TreePosRoundsTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,205 @@
+/*
+ * 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 6985205 6986246
+ * @summary access to tree positions and doc comments may be lost across annotation processing rounds
+ * @build TreePosRoundsTest
+ * @compile -proc:only -processor TreePosRoundsTest TreePosRoundsTest.java
+ * @run main TreePosRoundsTest
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+import javax.tools.JavaCompiler.CompilationTask;
+
+// This test is an annotation processor that performs multiple rounds of
+// processing, and on each round, it checks that source positions are
+// available and correct.
+//
+// The test can be run directly as a processor from the javac command line
+// or via JSR 199 by invoking the main program.
+
+@SupportedAnnotationTypes("*")
+public class TreePosRoundsTest extends AbstractProcessor {
+    public static void main(String... args) throws Exception {
+        String testSrc = System.getProperty("test.src");
+        String testClasses = System.getProperty("test.classes");
+        JavaCompiler c = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = c.getStandardFileManager(null, null, null);
+        String thisName = TreePosRoundsTest.class.getName();
+        File thisFile = new File(testSrc, thisName + ".java");
+        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(thisFile);
+        List<String> options = Arrays.asList(
+                "-proc:only",
+                "-processor", thisName,
+                "-processorpath", testClasses);
+        CompilationTask t = c.getTask(null, fm, null, options, null, files);
+        boolean ok = t.call();
+        if (!ok)
+            throw new Exception("processing failed");
+    }
+
+    Filer filer;
+    Messager messager;
+    Trees trees;
+
+    @Override
+    public SourceVersion getSupportedSourceVersion() {
+        return SourceVersion.latest();
+    }
+
+    @Override
+    public void init(ProcessingEnvironment pEnv) {
+        super.init(pEnv);
+        filer = pEnv.getFiler();
+        messager = pEnv.getMessager();
+        trees = Trees.instance(pEnv);
+    }
+
+    int round = 0;
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+
+        // Scan trees for elements, verifying source tree positions
+        for (Element e: roundEnv.getRootElements()) {
+            try {
+                TreePath p = trees.getPath(e);
+                new TestTreeScanner(p.getCompilationUnit(), trees).scan(trees.getPath(e), null);
+            } catch (IOException ex) {
+                messager.printMessage(Diagnostic.Kind.ERROR,
+                        "Cannot get source: " + ex, e);
+            }
+        }
+
+        final int MAXROUNDS = 3;
+        if (round < MAXROUNDS)
+            generateSource("Gen" + round);
+
+        return true;
+    }
+
+    void generateSource(String name) {
+        StringBuilder text = new StringBuilder();
+        text.append("class ").append(name).append("{\n");
+        text.append("    int one = 1;\n");
+        text.append("    int two = 2;\n");
+        text.append("    int three = one + two;\n");
+        text.append("}\n");
+
+        try {
+            JavaFileObject fo = filer.createSourceFile(name);
+            Writer out = fo.openWriter();
+            try {
+                out.write(text.toString());
+            } finally {
+                out.close();
+            }
+        } catch (IOException e) {
+            throw new Error(e);
+        }
+    }
+
+    class TestTreeScanner extends TreePathScanner<Void,Void> {
+        TestTreeScanner(CompilationUnitTree unit, Trees trees) throws IOException {
+            this.unit = unit;
+            JavaFileObject sf = unit.getSourceFile();
+            source = sf.getCharContent(true).toString();
+            sourcePositions = trees.getSourcePositions();
+        }
+
+        @Override
+        public Void visitVariable(VariableTree tree, Void _) {
+            check(getCurrentPath());
+            return super.visitVariable(tree, _);
+        }
+
+        void check(TreePath tp) {
+            Tree tree = tp.getLeaf();
+
+            String expect = tree.toString();
+            if (tree.getKind() == Tree.Kind.VARIABLE) {
+                // tree.toString() does not know enough context to add ";",
+                // so deal with that manually...
+                Tree.Kind enclKind = tp.getParentPath().getLeaf().getKind();
+                //System.err.println("  encl: " +enclKind);
+                if (enclKind == Tree.Kind.CLASS || enclKind == Tree.Kind.BLOCK)
+                    expect += ";";
+            }
+            //System.err.println("expect: " + expect);
+
+            int start = (int)sourcePositions.getStartPosition(unit, tree);
+            if (start == Diagnostic.NOPOS) {
+                messager.printMessage(Diagnostic.Kind.ERROR, "start pos not set for " + trim(tree));
+                return;
+            }
+
+            int end = (int)sourcePositions.getEndPosition(unit, tree);
+            if (end == Diagnostic.NOPOS) {
+                messager.printMessage(Diagnostic.Kind.ERROR, "end pos not set for " + trim(tree));
+                return;
+            }
+
+            String found = source.substring(start, end);
+            //System.err.println(" found: " + found);
+
+            // allow for long lines, in which case just compare beginning and
+            // end of the strings
+            boolean equal;
+            if (found.contains("\n")) {
+                String head = found.substring(0, found.indexOf("\n"));
+                String tail = found.substring(found.lastIndexOf("\n")).trim();
+                equal = expect.startsWith(head) && expect.endsWith(tail);
+            } else {
+                equal = expect.equals(found);
+            }
+
+            if (!equal) {
+                messager.printMessage(Diagnostic.Kind.ERROR,
+                        "unexpected value found: '" + found + "'; expected: '" + expect + "'");
+            }
+        }
+
+        String trim(Tree tree) {
+            final int MAXLEN = 32;
+            String s = tree.toString().replaceAll("\\s+", " ").trim();
+            return (s.length() < MAXLEN) ? s : s.substring(0, MAXLEN);
+
+        }
+
+        CompilationUnitTree unit;
+        SourcePositions sourcePositions;
+        String source;
+    }
+
+}
--- a/test/tools/javac/tree/TreeScannerTest.java	Tue Sep 14 11:37:19 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,387 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/**
- * Utility and test program to check javac's internal TreeScanner class.
- * The program can be run standalone, or as a jtreg test.  For info on
- * command line args, run program with no args.
- *
- * <p>
- * jtreg: Note that by using the -r switch in the test description below, this test
- * will process all java files in the langtools/test directory, thus implicitly
- * covering any new language features that may be tested in this test suite.
- */
-
-/*
- * @test
- * @bug 6923080
- * @summary TreeScanner.visitNewClass should scan tree.typeargs
- * @run main TreeScannerTest -q -r .
- */
-
-import java.io.*;
-import java.lang.reflect.*;
-import java.util.*;
-import javax.tools.*;
-
-import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.util.JavacTask;
-import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.util.List;
-
-public class TreeScannerTest {
-    /**
-     * Main entry point.
-     * If test.src is set, program runs in jtreg mode, and will throw an Error
-     * if any errors arise, otherwise System.exit will be used. In jtreg mode,
-     * the default base directory for file args is the value of ${test.src}.
-     * In jtreg mode, the -r option can be given to change the default base
-     * directory to the root test directory.
-     */
-    public static void main(String... args) {
-        String testSrc = System.getProperty("test.src");
-        File baseDir = (testSrc == null) ? null : new File(testSrc);
-        boolean ok = new TreeScannerTest().run(baseDir, args);
-        if (!ok) {
-            if (testSrc != null)  // jtreg mode
-                throw new Error("failed");
-            else
-                System.exit(1);
-        }
-    }
-
-    /**
-     * Run the program. A base directory can be provided for file arguments.
-     * In jtreg mode, the -r option can be given to change the default base
-     * directory to the test root directory. For other options, see usage().
-     * @param baseDir base directory for any file arguments.
-     * @param args command line args
-     * @return true if successful or in gui mode
-     */
-    boolean run(File baseDir, String... args) {
-        if (args.length == 0) {
-            usage(System.out);
-            return true;
-        }
-
-        ArrayList<File> files = new ArrayList<File>();
-        for (int i = 0; i < args.length; i++) {
-            String arg = args[i];
-            if (arg.equals("-q"))
-                quiet = true;
-            else if (arg.equals("-v"))
-                verbose = true;
-            else if (arg.equals("-r")) {
-                File d = baseDir;
-                while (!new File(d, "TEST.ROOT").exists()) {
-                    d = d.getParentFile();
-                    if (d == null)
-                        throw new Error("cannot find TEST.ROOT");
-                }
-                baseDir = d;
-            }
-            else if (arg.startsWith("-"))
-                throw new Error("unknown option: " + arg);
-            else {
-                while (i < args.length)
-                    files.add(new File(baseDir, args[i++]));
-            }
-        }
-
-        for (File file: files) {
-            if (file.exists())
-                test(file);
-            else
-                error("File not found: " + file);
-        }
-
-        if (fileCount != 1)
-            System.err.println(fileCount + " files read");
-        if (errors > 0)
-            System.err.println(errors + " errors");
-
-        return (errors == 0);
-    }
-
-    /**
-     * Print command line help.
-     * @param out output stream
-     */
-    void usage(PrintStream out) {
-        out.println("Usage:");
-        out.println("  java TreeScannerTest options... files...");
-        out.println("");
-        out.println("where options include:");
-        out.println("-q        Quiet: don't report on inapplicable files");
-        out.println("-v        Verbose: report on files as they are being read");
-        out.println("");
-        out.println("files may be directories or files");
-        out.println("directories will be scanned recursively");
-        out.println("non java files, or java files which cannot be parsed, will be ignored");
-        out.println("");
-    }
-
-    /**
-     * Test a file. If the file is a directory, it will be recursively scanned
-     * for java files.
-     * @param file the file or directory to test
-     */
-    void test(File file) {
-        if (file.isDirectory()) {
-            for (File f: file.listFiles()) {
-                test(f);
-            }
-            return;
-        }
-
-        if (file.isFile() && file.getName().endsWith(".java")) {
-            try {
-                if (verbose)
-                    System.err.println(file);
-                fileCount++;
-                ScanTester t = new ScanTester();
-                t.test(read(file));
-            } catch (ParseException e) {
-                if (!quiet) {
-                    error("Error parsing " + file + "\n" + e.getMessage());
-                }
-            } catch (IOException e) {
-                error("Error reading " + file + ": " + e);
-            }
-            return;
-        }
-
-        if (!quiet)
-            error("File " + file + " ignored");
-    }
-
-    /**
-     * Read a file.
-     * @param file the file to be read
-     * @return the tree for the content of the file
-     * @throws IOException if any IO errors occur
-     * @throws TreePosTest.ParseException if any errors occur while parsing the file
-     */
-    JCCompilationUnit read(File file) throws IOException, ParseException {
-        StringWriter sw = new StringWriter();
-        PrintWriter pw = new PrintWriter(sw);
-        Reporter r = new Reporter(pw);
-        JavacTool tool = JavacTool.create();
-        StandardJavaFileManager fm = tool.getStandardFileManager(r, null, null);
-        Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(file);
-        JavacTask task = tool.getTask(pw, fm, r, Collections.<String>emptyList(), null, files);
-        Iterable<? extends CompilationUnitTree> trees = task.parse();
-        pw.flush();
-        if (r.errors > 0)
-            throw new ParseException(sw.toString());
-        Iterator<? extends CompilationUnitTree> iter = trees.iterator();
-        if (!iter.hasNext())
-            throw new Error("no trees found");
-        JCCompilationUnit t = (JCCompilationUnit) iter.next();
-        if (iter.hasNext())
-            throw new Error("too many trees found");
-        return t;
-    }
-
-    /**
-     * Report an error. When the program is complete, the program will either
-     * exit or throw an Error if any errors have been reported.
-     * @param msg the error message
-     */
-    void error(String msg) {
-        System.err.println(msg);
-        errors++;
-    }
-
-    /**
-     *  Report an error for a specific tree node.
-     *  @param file the source file for the tree
-     *  @param t    the tree node
-     *  @param label an indication of the error
-     */
-    void error(JavaFileObject file, JCTree t, String msg) {
-        error(file.getName() + ":" + getLine(file, t) + ": " + msg + " " + trim(t, 64));
-    }
-
-    /**
-     * Get a trimmed string for a tree node, with normalized white space and limited length.
-     */
-    String trim(JCTree t, int len) {
-        String s = t.toString().replaceAll("[\r\n]+", " ").replaceAll(" +", " ");
-        return (s.length() < len) ? s : s.substring(0, len);
-    }
-
-    /** Number of files that have been analyzed. */
-    int fileCount;
-    /** Number of errors reported. */
-    int errors;
-    /** Flag: don't report irrelevant files. */
-    boolean quiet;
-    /** Flag: report files as they are processed. */
-    boolean verbose;
-
-    /**
-     * Main class for testing operation of tree scanner.
-     * The set of nodes found by the scanner are compared
-     * against the set of nodes found by reflection.
-     */
-    private class ScanTester extends TreeScanner {
-        /** Main entry method for the class. */
-        void test(JCCompilationUnit tree) {
-            sourcefile = tree.sourcefile;
-            found = new HashSet<JCTree>();
-            scan(tree);
-            expect = new HashSet<JCTree>();
-            reflectiveScan(tree);
-            if (found.equals(expect))
-                return;
-
-            error("Differences found for " + tree.sourcefile.getName());
-
-            if (found.size() != expect.size())
-                error("Size mismatch; found: " + found.size() + ", expected: " + expect.size());
-
-            Set<JCTree> missing = new HashSet<JCTree>();
-            missing.addAll(expect);
-            missing.removeAll(found);
-            for (JCTree t: missing)
-                error(tree.sourcefile, t, "missing");
-
-            Set<JCTree> excess = new HashSet<JCTree>();
-            excess.addAll(found);
-            excess.removeAll(expect);
-            for (JCTree t: excess)
-                error(tree.sourcefile, t, "unexpected");
-        }
-
-        /** Record all tree nodes found by scanner. */
-        @Override
-        public void scan(JCTree tree) {
-            if (tree == null)
-                return;
-            System.err.println("FOUND: " + tree.getTag() + " " + trim(tree, 64));
-            found.add(tree);
-            super.scan(tree);
-        }
-
-        /** record all tree nodes found by reflection. */
-        public void reflectiveScan(Object o) {
-            if (o == null)
-                return;
-            if (o instanceof JCTree) {
-                JCTree tree = (JCTree) o;
-                System.err.println("EXPECT: " + tree.getTag() + " " + trim(tree, 64));
-                expect.add(tree);
-                for (Field f: getFields(tree)) {
-                    try {
-                        //System.err.println("FIELD: " + f.getName());
-                        reflectiveScan(f.get(tree));
-                    } catch (IllegalAccessException e) {
-                        error(e.toString());
-                    }
-                }
-            } else if (o instanceof List) {
-                List<?> list = (List<?>) o;
-                for (Object item: list)
-                    reflectiveScan(item);
-            } else
-                error("unexpected item: " + o);
-        }
-
-        JavaFileObject sourcefile;
-        Set<JCTree> found;
-        Set<JCTree> expect;
-    }
-
-    /**
-     * Thrown when errors are found parsing a java file.
-     */
-    private static class ParseException extends Exception {
-        ParseException(String msg) {
-            super(msg);
-        }
-    }
-
-    /**
-     * DiagnosticListener to report diagnostics and count any errors that occur.
-     */
-    private static class Reporter implements DiagnosticListener<JavaFileObject> {
-        Reporter(PrintWriter out) {
-            this.out = out;
-        }
-
-        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
-            out.println(diagnostic);
-            switch (diagnostic.getKind()) {
-                case ERROR:
-                    errors++;
-            }
-        }
-        int errors;
-        PrintWriter out;
-    }
-
-    /**
-     * Get the set of fields for a tree node that may contain child tree nodes.
-     * These are the fields that are subtypes of JCTree or List.
-     * The results are cached, based on the tree's tag.
-     */
-    Set<Field> getFields(JCTree tree) {
-        Set<Field> fields = map.get(tree.getTag());
-        if (fields == null) {
-            fields = new HashSet<Field>();
-            for (Field f: tree.getClass().getFields()) {
-                Class<?> fc = f.getType();
-                if (JCTree.class.isAssignableFrom(fc) || List.class.isAssignableFrom(fc))
-                    fields.add(f);
-            }
-            map.put(tree.getTag(), fields);
-        }
-        return fields;
-    }
-    // where
-    Map<Integer, Set<Field>> map = new HashMap<Integer,Set<Field>>();
-
-    /** Get the line number for the primary position for a tree.
-     * The code is intended to be simple, although not necessarily efficient.
-     * However, note that a file manager such as JavacFileManager is likely
-     * to cache the results of file.getCharContent, avoiding the need to read
-     * the bits from disk each time this method is called.
-     */
-    int getLine(JavaFileObject file, JCTree tree) {
-        try {
-            CharSequence cs = file.getCharContent(true);
-            int line = 1;
-            for (int i = 0; i < tree.pos; i++) {
-                if (cs.charAt(i) == '\n') // jtreg tests always use Unix line endings
-                    line++;
-            }
-            return line;
-        } catch (IOException e) {
-            return -1;
-        }
-    }
-}
--- a/test/tools/javadoc/T4994049/FileWithTabs.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javadoc/T4994049/FileWithTabs.java	Wed Nov 10 19:07:04 2010 +0000
@@ -22,5 +22,5 @@
  */
 
 public class FileWithTabs {
-        public void tabbedMethod() {}
+\tpublic void tabbedMethod() {}
 }
--- a/test/tools/javadoc/T4994049/T4994049.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javadoc/T4994049/T4994049.java	Wed Nov 10 19:07:04 2010 +0000
@@ -30,7 +30,7 @@
  */
 
 import com.sun.javadoc.*;
-import java.io.File;
+import java.io.*;
 import static com.sun.tools.javadoc.Main.execute;
 
 public class T4994049 extends Doclet {
@@ -52,12 +52,47 @@
         return false;
     }
 
-    public static void main(String... args) {
+    public static void main(String... args) throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File tmpSrc = new File("tmpSrc");
+        initTabs(testSrc, tmpSrc);
+
         for (String file : args) {
-            File source = new File(System.getProperty("test.src", "."), file);
-            if (execute("javadoc", "T4994049", T4994049.class.getClassLoader(),
-                        new String[]{source.getPath()} ) != 0)
-                throw new Error();
+            File source = new File(tmpSrc, file);
+            int rc = execute("javadoc", "T4994049", T4994049.class.getClassLoader(),
+                        new String[]{ source.getPath() } );
+            if (rc != 0)
+                throw new Error("Unexpected return code from javadoc: " + rc);
+        }
+    }
+
+    static void initTabs(File from, File to) throws IOException {
+        for (File f: from.listFiles()) {
+            File t = new File(to, f.getName());
+            if (f.isDirectory()) {
+                initTabs(f, t);
+            } else if (f.getName().endsWith(".java")) {
+                write(t, read(f).replace("\\t", "\t"));
+            }
+        }
+    }
+
+    static String read(File f) throws IOException {
+        StringBuilder sb = new StringBuilder();
+        try (BufferedReader in = new BufferedReader(new FileReader(f))) {
+            String line;
+            while ((line = in.readLine()) != null) {
+                sb.append(line);
+                sb.append("\n");
+            }
+        }
+        return sb.toString();
+    }
+
+    static void write(File f, String s) throws IOException {
+        f.getParentFile().mkdirs();
+        try (Writer out = new FileWriter(f)) {
+            out.write(s);
         }
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javah/4942232/ParamClassTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+public class ParamClassTest {
+    static {
+        System.loadLibrary("Test");
+    }
+
+    public native void method(Param s);
+
+    public static void main(String[] a) {
+    }
+}
+
+class Param {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javah/4942232/Test.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4942232
+ * @summary missing param class processes without error
+ * @build ParamClassTest Test
+ * @run main Test
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class Test {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    void run() throws Exception {
+        File testSrc = new File(System.getProperty("test.src"));
+        File testClasses = new File(System.getProperty("test.classes"));
+
+        // standard use of javah on valid class file
+        String[] test1Args = {
+            "-d", mkdir("test1/out").getPath(),
+            "-classpath", testClasses.getPath(),
+            "ParamClassTest"
+        };
+        test(test1Args, 0);
+
+        // extended use of javah on valid source file
+        String[] test2Args = {
+            "-d", mkdir("test2/out").getPath(),
+            "-classpath", testSrc.getPath(),
+            "ParamClassTest"
+        };
+        test(test2Args, 0);
+
+        // javah on class file with missing referents
+        File test3Classes = mkdir("test3/classes");
+        copy(new File(testClasses, "ParamClassTest.class"), test3Classes);
+        String[] test3Args = {
+            "-d", mkdir("test3/out").getPath(),
+            "-classpath", test3Classes.getPath(),
+            "ParamClassTest"
+        };
+        test(test3Args, 1);
+
+        // javah on source file with missing referents
+        File test4Src = mkdir("test4/src");
+        String paramClassTestSrc = readFile(new File(testSrc, "ParamClassTest.java"));
+        writeFile(new File(test4Src, "ParamClassTest.java"),
+                paramClassTestSrc.replaceAll("class Param \\{\\s+\\}", ""));
+        String[] test4Args = {
+            "-d", mkdir("test4/out").getPath(),
+            "-classpath", test4Src.getPath(),
+            "ParamClassTest"
+        };
+        test(test4Args, 15);
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(String[] args, int expect) {
+        System.err.println("test: " + Arrays.asList(args));
+        int rc = javah(args);
+        if (rc != expect)
+            error("Unexpected return code: " + rc + "; expected: " + expect);
+    }
+
+    int javah(String... args) {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javah.Main.run(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        return rc;
+    }
+
+    File mkdir(String path) {
+        File f = new File(path);
+        f.mkdirs();
+        return f;
+    }
+
+    void copy(File from, File to) throws IOException {
+        if (to.isDirectory())
+            to = new File(to, from.getName());
+        try (DataInputStream in = new DataInputStream(new FileInputStream(from));
+                FileOutputStream out = new FileOutputStream(to)) {
+            byte[] buf = new byte[(int) from.length()];
+            in.readFully(buf);
+            out.write(buf);
+        }
+    }
+
+    String readFile(File f) throws IOException {
+        try (DataInputStream in = new DataInputStream(new FileInputStream(f))) {
+            byte[] buf = new byte[(int) f.length()];
+            in.readFully(buf);
+            return new String(buf);
+        }
+    }
+
+    void writeFile(File f, String body) throws IOException {
+        try (FileWriter out = new FileWriter(f)) {
+            out.write(body);
+        }
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javah/TestHelpOpts.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,81 @@
+/*
+ * 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 6893932 6990390
+ * @summary javah help screen lists -h and -? but does not accept them
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class TestHelpOpts {
+    public static void main(String... args) throws Exception {
+        new TestHelpOpts().run();
+    }
+
+    void run() throws Exception {
+        Locale prev = Locale.getDefault();
+        try {
+            Locale.setDefault(Locale.ENGLISH);
+
+            String[] opts = { "-h", "-help", "-?", "--help" };
+            for (String opt: opts)
+                test(opt);
+        } finally {
+            Locale.setDefault(prev);
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(String opt) {
+        System.err.println("test " + opt);
+        String[] args = { opt };
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javah.Main.run(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            error("Unexpected exit: rc=" + rc);
+
+        String flat = out.replaceAll("\\s+", " "); // canonicalize whitespace
+        if (!flat.contains("Usage: javah [options] <classes> where [options] include:"))
+            error("expected text not found");
+        if (flat.contains("main.opt"))
+            error("key not found in resource bundle: " + flat.replaceAll(".*(main.opt.[^ ]*).*", "$1"));
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javah/VersionTest.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,59 @@
+/*
+ * 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 6890226
+ * @summary javah -version is broken
+ */
+
+import java.io.*;
+import java.util.Locale;
+
+public class VersionTest {
+    public static void main(String... args) {
+        Locale prev = Locale.getDefault();
+        try {
+            Locale.setDefault(Locale.ENGLISH);
+            System.err.println(Locale.getDefault());
+            test("-version", "\\S+ version \"\\S+\"");
+            test("-fullversion", "\\S+ full version \"\\S+\"");
+        } finally {
+            Locale.setDefault(prev);
+        }
+    }
+
+    static void test(String option, String regex) {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        String[] args = { option };
+        int rc = com.sun.tools.javah.Main.run(args, pw);
+        pw.close();
+        if (rc != 0)
+            throw new Error("javah failed: rc=" + rc);
+        String out = sw.toString().trim();
+        System.err.println(out);
+        if (!out.matches(regex))
+            throw new Error("output does not match pattern: " + regex);
+    }
+}
--- a/test/tools/javap/T6868539.java	Tue Sep 14 11:37:19 2010 +0100
+++ b/test/tools/javap/T6868539.java	Wed Nov 10 19:07:04 2010 +0000
@@ -39,25 +39,25 @@
     }
 
     void run() {
-        verify("T6868539", "Utf8 +java/lang/String");                                   // 1: Utf8
+        String output = javap("T6868539");
+        verify(output, "Utf8 +java/lang/String");                                   // 1: Utf8
                                                                                         // 2: currently unused
-        verify("T6868539", "Integer +123456");                                          // 3: Integer
-        verify("T6868539", "Float +123456.0f");                                         // 4: Float
-        verify("T6868539", "Long +123456l");                                            // 5: Long
-        verify("T6868539", "Double +123456.0d");                                        // 6: Double
-        verify("T6868539", "Class +#[0-9]+ +// + T6868539");                            // 7: Class
-        verify("T6868539", "String +#[0-9]+ +// + not found");                          // 8: String
-        verify("T6868539", "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I");       // 9: Fieldref
-        verify("T6868539", "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V");   // 10: Methodref
-        verify("T6868539", "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
+        verify(output, "Integer +123456");                                          // 3: Integer
+        verify(output, "Float +123456.0f");                                         // 4: Float
+        verify(output, "Long +123456l");                                            // 5: Long
+        verify(output, "Double +123456.0d");                                        // 6: Double
+        verify(output, "Class +#[0-9]+ +// + T6868539");                            // 7: Class
+        verify(output, "String +#[0-9]+ +// + not found");                          // 8: String
+        verify(output, "Fieldref +#[0-9]+\\.#[0-9]+ +// +T6868539.errors:I");       // 9: Fieldref
+        verify(output, "Methodref +#[0-9]+\\.#[0-9]+ +// +T6868539.run:\\(\\)V");   // 10: Methodref
+        verify(output, "InterfaceMethodref +#[0-9]+\\.#[0-9]+ +// +java/lang/Runnable\\.run:\\(\\)V");
                                                                                         // 11: InterfaceMethodref
-        verify("T6868539", "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V");            // 12: NameAndType
+        verify(output, "NameAndType +#[0-9]+:#[0-9]+ +// +run:\\(\\)V");            // 12: NameAndType
         if (errors > 0)
             throw new Error(errors + " found.");
     }
 
-    void verify(String className, String... expects) {
-        String output = javap(className);
+    void verify(String output, String... expects) {
         for (String expect: expects) {
             if (!output.matches("(?s).*" + expect + ".*"))
                 error(expect + " not found");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javap/T6980017.java	Wed Nov 10 19:07:04 2010 +0000
@@ -0,0 +1,78 @@
+/*
+ * 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 6980017
+ * @summary javap -XDdetail:source behaves badly if source not available.
+ */
+
+import java.io.*;
+
+public class T6980017 {
+    public static void main(String... args) throws Exception {
+        new T6980017().run();
+    }
+
+    void run() throws Exception {
+
+        String[] args = {
+            "-v",
+            "-XDdetails:source",
+            "java.lang.Object"
+        };
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javap.Main.run(args, pw);
+        pw.close();
+        if (rc != 0)
+            error("Unexpected exit code: " + rc);
+
+        boolean foundBlankSourceLine = false;
+        boolean foundNoSourceLine = false;
+        for (String line: sw.toString().split("[\r\n]+")) {
+            System.err.println(line);
+            if (line.contains("Source code not available"))
+                foundNoSourceLine = true;
+            if (line.matches("\\s*\\( *[0-9]+\\)\\s*"))
+                foundBlankSourceLine = true;
+        }
+
+        if (foundBlankSourceLine)
+            error("found blank source lines");
+
+        if (!foundNoSourceLine)
+            error("did not find \"Source code not available\" message");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void error(String msg) {
+        System.err.println(msg);
+        errors++;
+    }
+
+    int errors;
+}