Merge
authorlana
Thu, 10 Mar 2011 20:51:07 -0800
changeset 8638 a22e7a4637b3
parent 8609 5e102ef6a2fd (current diff)
parent 8637 be1b564b50aa (diff)
child 8641 fbf4a969ccba
Merge
langtools/test/tools/javac/T6900037.java
langtools/test/tools/javac/T6900037.out
langtools/test/tools/javac/diags/examples/DiamondInvalidArg.java
langtools/test/tools/javac/diags/examples/DiamondInvalidArgs.java
langtools/test/tools/javac/generics/diamond/neg/Neg12.java
langtools/test/tools/javac/generics/diamond/neg/Neg12.out
langtools/test/tools/javac/multicatch/Neg05.java
langtools/test/tools/javac/multicatch/Neg05.out
--- a/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -280,7 +280,7 @@
         }
 
         if (verbose)
-            printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
+            log.printVerbose("total", Long.toString(System.currentTimeMillis() - msec));
 
         chk.reportDeferredDiagnostics();
 
--- a/langtools/src/share/classes/com/sun/tools/apt/util/Bark.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/apt/util/Bark.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,15 +48,15 @@
      * Preregisters factories to create and use a Bark object for use as
      * both a Log and a Bark.
      */
-    public static void preRegister(final Context context) {
+    public static void preRegister(Context context) {
         context.put(barkKey, new Context.Factory<Bark>() {
-            public Bark make() {
-                return new Bark(context);
+            public Bark make(Context c) {
+                return new Bark(c);
             }
         });
         context.put(Log.logKey, new Context.Factory<Log>() {
-            public Log make() {
-                return Bark.instance(context);
+            public Log make(Context c) {
+                return Bark.instance(c);
             }
         });
     }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -156,7 +156,7 @@
         if (index < 0) {
             return htmlstr;
         }
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         int previndex = 0;
         while (true) {
             // Search for lowercase version of {@docRoot}
@@ -2279,7 +2279,7 @@
      */
     public String commentTagsToString(Tag holderTag, Doc doc, Tag[] tags,
             boolean isFirstSentence) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         // Array of all possible inline tags for this javadoc run
         configuration.tagletManager.checkTags(doc, tags, true);
         for (int i = 0; i < tags.length; i++) {
@@ -2315,7 +2315,7 @@
                 StringTokenizer lines = new StringTokenizer(text, "\r\n", true);
                 StringBuffer textBuff = new StringBuffer();
                 while (lines.hasMoreTokens()) {
-                    StringBuffer line = new StringBuffer(lines.nextToken());
+                    StringBuilder line = new StringBuilder(lines.nextToken());
                     Util.replaceTabs(configuration.sourcetab, line);
                     textBuff.append(line.toString());
                 }
@@ -2473,7 +2473,7 @@
                 return text;
             }
             int endindex = startindex + tobe.length();
-            StringBuffer replaced = new StringBuffer();
+            StringBuilder replaced = new StringBuilder();
             if (startindex > 0) {
                 replaced.append(text.substring(0, startindex));
             }
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 import com.sun.javadoc.*;
 import com.sun.tools.doclets.internal.toolkit.*;
 import com.sun.tools.doclets.internal.toolkit.taglets.*;
-import com.sun.tools.doclets.internal.toolkit.util.*;
 import com.sun.tools.doclets.formats.html.markup.*;
 
 /**
@@ -53,7 +52,7 @@
     }
 
     public List<FieldDoc> members(ClassDoc cd) {
-        return Util.asList(cd.serializableFields());
+        return Arrays.asList(cd.serializableFields());
     }
 
     protected void printTypeLinkNoDimension(Type type) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -266,7 +266,7 @@
     private static void addLine(Content pre, String line, int tabLength,
             int currentLineNo) {
         if (line != null) {
-            StringBuffer lineBuffer = new StringBuffer(Util.escapeHtmlChars(line));
+            StringBuilder lineBuffer = new StringBuilder(Util.escapeHtmlChars(line));
             Util.replaceTabs(tabLength, lineBuffer);
             pre.addContent(new RawHtml(lineBuffer.toString()));
             Content anchor = HtmlTree.A_NAME("line." + Integer.toString(currentLineNo));
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -375,8 +375,7 @@
      */
     public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) {
         if (classDoc.definesSerializableFields()) {
-            FieldDoc serialPersistentField =
-                Util.asList(classDoc.serializableFields()).get(0);
+            FieldDoc serialPersistentField = classDoc.serializableFields()[0];
             // Check to see if there are inline comments, tags or deprecation
             // information to be printed.
             if (fieldWriter.shouldPrintOverview(serialPersistentField)) {
--- a/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -382,7 +382,7 @@
                 out.close();
             }
         } catch (IOException ie) {
-            ie.printStackTrace();
+            ie.printStackTrace(System.err);
             throw new DocletAbortException();
         }
     }
@@ -399,12 +399,12 @@
             String pkgPath = DirectoryManager.getDirectoryPath(pkgDoc);
             String completePath = new SourcePath(configuration.sourcepath).
                 getDirectory(pkgPath) + DirectoryManager.URL_FILE_SEPARATOR;
-            //Make sure that both paths are using the same seperators.
+            //Make sure that both paths are using the same separators.
             completePath = Util.replaceText(completePath, File.separator,
                     DirectoryManager.URL_FILE_SEPARATOR);
             pkgPath = Util.replaceText(pkgPath, File.separator,
                     DirectoryManager.URL_FILE_SEPARATOR);
-            return completePath.substring(0, completePath.indexOf(pkgPath));
+            return completePath.substring(0, completePath.lastIndexOf(pkgPath));
         } catch (Exception e){
             return "";
         }
@@ -536,15 +536,6 @@
             findAllInterfaceTypes(results, (ClassDoc) type, true, configuration);
     }
 
-
-    public static <T extends ProgramElementDoc> List<T> asList(T[] members) {
-        List<T> list = new ArrayList<T>();
-        for (int i = 0; i < members.length; i++) {
-            list.add(members[i]);
-        }
-        return list;
-    }
-
     /**
      * Enclose in quotes, used for paths and filenames that contains spaces
      */
@@ -583,14 +574,7 @@
         if (oldStr == null || newStr == null || oldStr.equals(newStr)) {
             return originalStr;
         }
-        StringBuffer result = new StringBuffer(originalStr);
-        int startIndex = 0;
-        while ((startIndex = result.indexOf(oldStr, startIndex)) != -1) {
-            result = result.replace(startIndex, startIndex + oldStr.length(),
-                    newStr);
-            startIndex += newStr.length();
-        }
-        return result.toString();
+        return originalStr.replace(oldStr, newStr);
     }
 
     /**
@@ -833,19 +817,17 @@
      * @param tabLength the length of each tab.
      * @param s the String to scan.
      */
-    public static void replaceTabs(int tabLength, StringBuffer s) {
-        int index, col;
-        StringBuffer whitespace;
-        while ((index = s.indexOf("\t")) != -1) {
-            whitespace = new StringBuffer();
-            col = index;
-            do {
-                whitespace.append(" ");
-                col++;
-            } while ((col%tabLength) != 0);
-            s.replace(index, index+1, whitespace.toString());
+    public static void replaceTabs(int tabLength, StringBuilder s) {
+        if (whitespace == null || whitespace.length() < tabLength)
+            whitespace = String.format("%" + tabLength + "s", " ");
+        int index = 0;
+        while ((index = s.indexOf("\t", index)) != -1) {
+            int spaceCount = tabLength - index % tabLength;
+            s.replace(index, index+1, whitespace.substring(0, spaceCount));
+            index += spaceCount;
         }
     }
+    private static String whitespace;
 
     /**
      * The documentation for values() and valueOf() in Enums are set by the
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -157,19 +157,19 @@
     /**
      * Register that a compilation is about to start.
      */
-    void beginContext(final Context context) {
+    void beginContext(Context context) {
         if (compilationInProgress)
             throw new IllegalStateException("Compilation in progress");
         compilationInProgress = true;
         final JavaFileManager givenFileManager = context.get(JavaFileManager.class);
         context.put(JavaFileManager.class, (JavaFileManager)null);
         context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
-            public JavaFileManager make() {
+            public JavaFileManager make(Context c) {
                 if (givenFileManager != null) {
-                    context.put(JavaFileManager.class, givenFileManager);
+                    c.put(JavaFileManager.class, givenFileManager);
                     return givenFileManager;
                 } else {
-                    return new JavacFileManager(context, true, null);
+                    return new JavacFileManager(c, true, null);
                 }
             }
         });
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java	Thu Mar 10 20:51:07 2011 -0800
@@ -43,7 +43,7 @@
     private Flags() {} // uninstantiable
 
     public static String toString(long flags) {
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         String sep = "";
         for (Flag s : asFlagSet(flags)) {
             buf.append(sep);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Kinds.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -163,6 +163,7 @@
         case PARAMETER:
         case LOCAL_VARIABLE:
         case EXCEPTION_PARAMETER:
+        case RESOURCE_VARIABLE:
             return KindName.VAR;
 
         case CONSTRUCTOR:
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Thu Mar 10 20:51:07 2011 -0800
@@ -831,6 +831,8 @@
                 ClassType t = (ClassType)type;
                 if (t.interfaces_field == null) // FIXME: shouldn't be null
                     t.interfaces_field = List.nil();
+                if (t.all_interfaces_field != null)
+                    return Type.getModelTypes(t.all_interfaces_field);
                 return t.interfaces_field;
             } else {
                 return List.nil();
@@ -846,7 +848,7 @@
                 // An interface has no superclass; its supertype is Object.
                 return t.isInterface()
                     ? Type.noType
-                    : t.supertype_field;
+                    : t.supertype_field.getModelType();
             } else {
                 return Type.noType;
             }
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symtab.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,8 @@
 package com.sun.tools.javac.code;
 
 import java.util.*;
+import javax.lang.model.type.TypeVisitor;
+import javax.lang.model.element.ElementVisitor;
 
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.List;
@@ -345,7 +347,12 @@
         target = Target.instance(context);
 
         // Create the unknown type
-        unknownType = new Type(TypeTags.UNKNOWN, null);
+        unknownType = new Type(TypeTags.UNKNOWN, null) {
+            @Override
+            public <R, P> R accept(TypeVisitor<R, P> v, P p) {
+                return v.visitUnknown(this, p);
+            }
+        };
 
         // create the basic builtin symbols
         rootPackage = new PackageSymbol(names.empty, null);
@@ -355,13 +362,20 @@
                     return messages.getLocalizedString("compiler.misc.unnamed.package");
                 }
             };
-        noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage);
+        noSymbol = new TypeSymbol(0, names.empty, Type.noType, rootPackage) {
+            public <R, P> R accept(ElementVisitor<R, P> v, P p) {
+                return v.visitUnknown(this, p);
+            }
+        };
         noSymbol.kind = Kinds.NIL;
 
         // create the error symbols
         errSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.any, null, rootPackage);
+        errType = new ErrorType(errSymbol, Type.noType);
+
         unknownSymbol = new ClassSymbol(PUBLIC|STATIC|ACYCLIC, names.fromString("<any?>"), null, rootPackage);
-        errType = new ErrorType(errSymbol, Type.noType);
+        unknownSymbol.members_field = new Scope.ErrorScope(unknownSymbol);
+        unknownSymbol.type = unknownType;
 
         // initialize builtin types
         initType(byteType, "byte", "Byte");
@@ -382,9 +396,11 @@
 
         // VGJ
         boundClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Bound, noSymbol);
+        boundClass.members_field = new Scope.ErrorScope(boundClass);
 
         // the builtin class of all methods
         methodClass = new ClassSymbol(PUBLIC|ACYCLIC, names.Method, noSymbol);
+        methodClass.members_field = new Scope.ErrorScope(boundClass);
 
         // Create class to hold all predefined constants and operations.
         predefClass = new ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Mar 10 20:51:07 2011 -0800
@@ -93,6 +93,22 @@
         return null;
     }
 
+    /**
+     * Get the representation of this type used for modelling purposes.
+     * By default, this is itself. For ErrorType, a different value
+     * may be provided,
+     */
+    public Type getModelType() {
+        return this;
+    }
+
+    public static List<Type> getModelTypes(List<Type> ts) {
+        ListBuffer<Type> lb = new ListBuffer<Type>();
+        for (Type t: ts)
+            lb.append(t.getModelType());
+        return lb.toList();
+    }
+
     public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); }
 
     /** Define a type given its tag and type symbol
@@ -190,7 +206,7 @@
         if (ts.isEmpty()) {
             return "";
         } else {
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             buf.append(ts.head.toString());
             for (List<Type> l = ts.tail; l.nonEmpty(); l = l.tail)
                 buf.append(",").append(l.head.toString());
@@ -464,7 +480,7 @@
 
         boolean isPrintingBound = false;
         public String toString() {
-            StringBuffer s = new StringBuffer();
+            StringBuilder s = new StringBuilder();
             s.append(kind.toString());
             if (kind != UNBOUND)
                 s.append(type);
@@ -538,6 +554,10 @@
          */
         public List<Type> interfaces_field;
 
+        /** All the interfaces of this class, including missing ones.
+         */
+        public List<Type> all_interfaces_field;
+
         public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) {
             super(CLASS, tsym);
             this.outer_field = outer;
@@ -578,7 +598,7 @@
         /** The Java source which this type represents.
          */
         public String toString() {
-            StringBuffer buf = new StringBuffer();
+            StringBuilder buf = new StringBuilder();
             if (getEnclosingType().tag == CLASS && tsym.owner.kind == TYP) {
                 buf.append(getEnclosingType().toString());
                 buf.append(".");
@@ -596,7 +616,7 @@
 //where
             private String className(Symbol sym, boolean longform) {
                 if (sym.name.isEmpty() && (sym.flags() & COMPOUND) != 0) {
-                    StringBuffer s = new StringBuffer(supertype_field.toString());
+                    StringBuilder s = new StringBuilder(supertype_field.toString());
                     for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) {
                         s.append("&");
                         s.append(is.head.toString());
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1992,7 +1992,11 @@
      * @return true if t is a sub signature of s.
      */
     public boolean isSubSignature(Type t, Type s) {
-        return hasSameArgs(t, s) || hasSameArgs(t, erasure(s));
+        return isSubSignature(t, s, true);
+    }
+
+    public boolean isSubSignature(Type t, Type s, boolean strict) {
+        return hasSameArgs(t, s, strict) || hasSameArgs(t, erasure(s), strict);
     }
 
     /**
@@ -2129,10 +2133,24 @@
      * where correspondence is by position in the type parameter list.
      */
     public boolean hasSameArgs(Type t, Type s) {
+        return hasSameArgs(t, s, true);
+    }
+
+    public boolean hasSameArgs(Type t, Type s, boolean strict) {
+        return hasSameArgs(t, s, strict ? hasSameArgs_strict : hasSameArgs_nonstrict);
+    }
+
+    private boolean hasSameArgs(Type t, Type s, TypeRelation hasSameArgs) {
         return hasSameArgs.visit(t, s);
     }
     // where
-        private TypeRelation hasSameArgs = new TypeRelation() {
+        private class HasSameArgs extends TypeRelation {
+
+            boolean strict;
+
+            public HasSameArgs(boolean strict) {
+                this.strict = strict;
+            }
 
             public Boolean visitType(Type t, Type s) {
                 throw new AssertionError();
@@ -2147,7 +2165,7 @@
             @Override
             public Boolean visitForAll(ForAll t, Type s) {
                 if (s.tag != FORALL)
-                    return false;
+                    return strict ? false : visitMethodType(t.asMethodType(), s);
 
                 ForAll forAll = (ForAll)s;
                 return hasSameBounds(t, forAll)
@@ -2159,6 +2177,10 @@
                 return false;
             }
         };
+
+        TypeRelation hasSameArgs_strict = new HasSameArgs(true);
+        TypeRelation hasSameArgs_nonstrict = new HasSameArgs(false);
+
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="subst">
@@ -2534,7 +2556,7 @@
     }
     // where
         private String typaramsString(List<Type> tvars) {
-            StringBuffer s = new StringBuffer();
+            StringBuilder s = new StringBuilder();
             s.append('<');
             boolean first = true;
             for (Type t : tvars) {
@@ -2545,7 +2567,7 @@
             s.append('>');
             return s.toString();
         }
-        private void appendTyparamString(TypeVar t, StringBuffer buf) {
+        private void appendTyparamString(TypeVar t, StringBuilder buf) {
             buf.append(t);
             if (t.bound == null ||
                 t.bound.tsym.getQualifiedName() == names.java_lang_Object)
@@ -2832,12 +2854,26 @@
             while (ts.head.tag != CLASS && ts.head.tag != TYPEVAR)
                 ts = ts.tail;
             Assert.check(!ts.isEmpty());
-            List<Type> cl = closure(ts.head);
+            //step 1 - compute erased candidate set (EC)
+            List<Type> cl = erasedSupertypes(ts.head);
             for (Type t : ts.tail) {
                 if (t.tag == CLASS || t.tag == TYPEVAR)
-                    cl = intersect(cl, closure(t));
+                    cl = intersect(cl, erasedSupertypes(t));
             }
-            return compoundMin(cl);
+            //step 2 - compute minimal erased candidate set (MEC)
+            List<Type> mec = closureMin(cl);
+            //step 3 - for each element G in MEC, compute lci(Inv(G))
+            List<Type> candidates = List.nil();
+            for (Type erasedSupertype : mec) {
+                List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym));
+                for (Type t : ts) {
+                    lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym)));
+                }
+                candidates = candidates.appendList(lci);
+            }
+            //step 4 - let MEC be { G1, G2 ... Gn }, then we have that
+            //lub = lci(Inv(G1)) & lci(Inv(G2)) & ... & lci(Inv(Gn))
+            return compoundMin(candidates);
 
         default:
             // calculate lub(A, B[])
@@ -2851,6 +2887,18 @@
         }
     }
     // where
+        List<Type> erasedSupertypes(Type t) {
+            ListBuffer<Type> buf = lb();
+            for (Type sup : closure(t)) {
+                if (sup.tag == TYPEVAR) {
+                    buf.append(sup);
+                } else {
+                    buf.append(erasure(sup));
+                }
+            }
+            return buf.toList();
+        }
+
         private Type arraySuperType = null;
         private Type arraySuperType() {
             // initialized lazily to avoid problems during compiler startup
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1425,7 +1425,7 @@
                             // qualifier omitted; check for existence
                             // of an appropriate implicit qualifier.
                             rs.resolveImplicitThis(tree.meth.pos(),
-                                                   localEnv, site);
+                                                   localEnv, site, true);
                         }
                     } else if (tree.meth.getTag() == JCTree.SELECT) {
                         log.error(tree.meth.pos(), "illegal.qual.not.icls",
@@ -1581,15 +1581,7 @@
         // symbol + type back into the attributed tree.
         Type clazztype = attribType(clazz, env);
         Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype, cdef != null);
-        if (!TreeInfo.isDiamond(tree)) {
-            clazztype = chk.checkClassType(
-                tree.clazz.pos(), clazztype, true);
-        } else if (!clazztype.isErroneous() &&
-                !clazztype.tsym.type.isParameterized()) {
-            log.error(tree.clazz.pos(),
-                    "cant.apply.diamond.1",
-                    clazztype, diags.fragment("diamond.non.generic", clazztype));
-        }
+        clazztype = chk.checkDiamond(tree, clazztype);
         chk.validate(clazz, localEnv);
         if (tree.encl != null) {
             // We have to work in this case to store
@@ -1614,10 +1606,12 @@
         List<Type> argtypes = attribArgs(tree.args, localEnv);
         List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
 
-        if (TreeInfo.isDiamond(tree) && clazztype.tsym.type.isParameterized()) {
+        if (TreeInfo.isDiamond(tree) && !clazztype.isErroneous()) {
             clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes);
             clazz.type = clazztype;
         } else if (allowDiamondFinder &&
+                tree.def == null &&
+                !clazztype.isErroneous() &&
                 clazztype.getTypeArguments().nonEmpty() &&
                 findDiamonds) {
             boolean prevDeferDiags = log.deferDiagnostics;
@@ -1641,8 +1635,7 @@
             if (inferred != null &&
                     !inferred.isErroneous() &&
                     inferred.tag == CLASS &&
-                    types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings) &&
-                    chk.checkDiamond((ClassType)inferred).isEmpty()) {
+                    types.isAssignable(inferred, pt.tag == NONE ? clazztype : pt, Warner.noWarnings)) {
                 String key = types.isSameType(clazztype, inferred) ?
                     "diamond.redundant.args" :
                     "diamond.redundant.args.1";
@@ -1857,34 +1850,9 @@
                         ex.diagnostic);
             }
         }
-        clazztype = chk.checkClassType(tree.clazz.pos(),
+        return chk.checkClassType(tree.clazz.pos(),
                 clazztype,
                 true);
-        if (clazztype.tag == CLASS) {
-            List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
-            if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
-                //one or more types inferred in the previous steps is either a
-                //captured type or an intersection type --- we need to report an error.
-                String subkey = invalidDiamondArgs.size() > 1 ?
-                    "diamond.invalid.args" :
-                    "diamond.invalid.arg";
-                //The error message is of the kind:
-                //
-                //cannot infer type arguments for {clazztype}<>;
-                //reason: {subkey}
-                //
-                //where subkey is a fragment of the kind:
-                //
-                //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
-                log.error(tree.clazz.pos(),
-                            "cant.apply.diamond.1",
-                            diags.fragment("diamond", clazztype.tsym),
-                            diags.fragment(subkey,
-                                           invalidDiamondArgs,
-                                           diags.fragment("diamond", clazztype.tsym)));
-            }
-        }
-        return clazztype;
     }
 
     /** Creates a synthetic scope containing fake generic constructors.
@@ -2806,7 +2774,7 @@
                                   sym.location());
                 owntype = new MethodType(owntype.getParameterTypes(),
                                          types.erasure(owntype.getReturnType()),
-                                         owntype.getThrownTypes(),
+                                         types.erasure(owntype.getThrownTypes()),
                                          syms.methodClass);
             }
             if (useVarargs) {
@@ -2980,7 +2948,7 @@
             // (see comment for TypeVar.bound).
             // In this case, generate a class tree that represents the
             // bound class, ...
-            JCTree extending;
+            JCExpression extending;
             List<JCExpression> implementing;
             if ((bs.head.tsym.flags() & INTERFACE) == 0) {
                 extending = tree.bounds.head;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Mar 10 20:51:07 2011 -0800
@@ -664,40 +664,25 @@
             return true;
     }
 
-    /** Check that the type inferred using the diamond operator does not contain
-     *  non-denotable types such as captured types or intersection types.
-     *  @param t the type inferred using the diamond operator
+    /** Check that usage of diamond operator is correct (i.e. diamond should not
+     * be used with non-generic classes or in anonymous class creation expressions)
      */
-    List<Type> checkDiamond(ClassType t) {
-        DiamondTypeChecker dtc = new DiamondTypeChecker();
-        ListBuffer<Type> buf = ListBuffer.lb();
-        for (Type arg : t.getTypeArguments()) {
-            if (!dtc.visit(arg, null)) {
-                buf.append(arg);
-            }
-        }
-        return buf.toList();
-    }
-
-    static class DiamondTypeChecker extends Types.SimpleVisitor<Boolean, Void> {
-        public Boolean visitType(Type t, Void s) {
-            return true;
-        }
-        @Override
-        public Boolean visitClassType(ClassType t, Void s) {
-            if (t.isCompound()) {
-                return false;
-            }
-            for (Type targ : t.getTypeArguments()) {
-                if (!visit(targ, s)) {
-                    return false;
-                }
-            }
-            return true;
-        }
-        @Override
-        public Boolean visitCapturedType(CapturedType t, Void s) {
-            return false;
+    Type checkDiamond(JCNewClass tree, Type t) {
+        if (!TreeInfo.isDiamond(tree) ||
+                t.isErroneous()) {
+            return checkClassType(tree.clazz.pos(), t, true);
+        } else if (tree.def != null) {
+            log.error(tree.clazz.pos(),
+                    "cant.apply.diamond.1",
+                    t, diags.fragment("diamond.and.anon.class", t));
+            return types.createErrorType(t);
+        } else if (!t.tsym.type.isParameterized()) {
+            log.error(tree.clazz.pos(),
+                "cant.apply.diamond.1",
+                t, diags.fragment("diamond.non.generic", t));
+            return types.createErrorType(t);
+        } else {
+            return t;
         }
     }
 
@@ -1679,7 +1664,8 @@
                             "(" + types.memberType(t2, s2).getParameterTypes() + ")");
                         return s2;
                     }
-                } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
+                } else if (checkNameClash((ClassSymbol)site.tsym, s1, s2) &&
+                        !checkCommonOverriderIn(s1, s2, site)) {
                     log.error(pos,
                             "name.clash.same.erasure.no.override",
                             s1, s1.location(),
@@ -2113,7 +2099,7 @@
                 if (s1 == s2 || !sym.overrides(s2, site.tsym, types, false)) continue;
                 //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
                 //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error
-                if (!types.isSubSignature(sym.type, types.memberType(site, s1)) &&
+                if (!types.isSubSignature(sym.type, types.memberType(site, s1), false) &&
                         types.hasSameArgs(s1.erasure(types), s2.erasure(types))) {
                     sym.flags_field |= CLASH;
                     String key = s2 == sym ?
@@ -2145,7 +2131,7 @@
         for (Symbol s : types.membersClosure(site).getElementsByName(sym.name, cf)) {
             //if (i) the signature of 'sym' is not a subsignature of m1 (seen as
             //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error
-            if (!types.isSubSignature(sym.type, types.memberType(site, s)) &&
+            if (!types.isSubSignature(sym.type, types.memberType(site, s), false) &&
                     types.hasSameArgs(s.erasure(types), sym.erasure(types))) {
                 log.error(pos,
                         "name.clash.same.erasure.no.hide",
@@ -2666,7 +2652,7 @@
                 if ((sym.flags() & VARARGS) != (e.sym.flags() & VARARGS)) {
                     varargsDuplicateError(pos, sym, e.sym);
                     return true;
-                } else if (sym.kind == MTH && !hasSameSignature(sym.type, e.sym.type)) {
+                } else if (sym.kind == MTH && !types.hasSameArgs(sym.type, e.sym.type, false)) {
                     duplicateErasureError(pos, sym, e.sym);
                     sym.flags_field |= CLASH;
                     return true;
@@ -2678,15 +2664,6 @@
         }
         return true;
     }
-    //where
-        boolean hasSameSignature(Type mt1, Type mt2) {
-            if (mt1.tag == FORALL && mt2.tag == FORALL) {
-                ForAll fa1 = (ForAll)mt1;
-                ForAll fa2 = (ForAll)mt2;
-                mt2 = types.subst(fa2, fa2.tvars, fa1.tvars);
-            }
-            return types.hasSameArgs(mt1.asMethodType(), mt2.asMethodType());
-        }
 
     /** Report duplicate declaration error.
      */
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java	Thu Mar 10 20:51:07 2011 -0800
@@ -272,7 +272,7 @@
 
     /** The list of unreferenced automatic resources.
      */
-    Map<VarSymbol, JCVariableDecl> unrefdResources;
+    Scope unrefdResources;
 
     /** Set when processing a loop body the second time for DU analysis. */
     boolean loopPassTwo = false;
@@ -804,14 +804,16 @@
         ListBuffer<PendingExit> prevPendingExits = pendingExits;
         boolean prevLoopPassTwo = loopPassTwo;
         pendingExits = new ListBuffer<PendingExit>();
+        int prevErrors = log.nerrors;
         do {
             Bits uninitsEntry = uninits.dup();
+            uninitsEntry.excludeFrom(nextadr);
             scanStat(tree.body);
             alive |= resolveContinues(tree);
             scanCond(tree.cond);
-            if (log.nerrors != 0 ||
+            if (log.nerrors !=  prevErrors ||
                 loopPassTwo ||
-                uninitsEntry.diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
+                uninitsEntry.dup().diffSet(uninitsWhenTrue).nextBit(firstadr)==-1)
                 break;
             inits = initsWhenTrue;
             uninits = uninitsEntry.andSet(uninitsWhenTrue);
@@ -831,8 +833,10 @@
         Bits initsCond;
         Bits uninitsCond;
         pendingExits = new ListBuffer<PendingExit>();
+        int prevErrors = log.nerrors;
         do {
             Bits uninitsEntry = uninits.dup();
+            uninitsEntry.excludeFrom(nextadr);
             scanCond(tree.cond);
             initsCond = initsWhenFalse;
             uninitsCond = uninitsWhenFalse;
@@ -841,9 +845,9 @@
             alive = !tree.cond.type.isFalse();
             scanStat(tree.body);
             alive |= resolveContinues(tree);
-            if (log.nerrors != 0 ||
+            if (log.nerrors != prevErrors ||
                 loopPassTwo ||
-                uninitsEntry.diffSet(uninits).nextBit(firstadr) == -1)
+                uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
                 break;
             uninits = uninitsEntry.andSet(uninits);
             loopPassTwo = true;
@@ -864,8 +868,10 @@
         Bits initsCond;
         Bits uninitsCond;
         pendingExits = new ListBuffer<PendingExit>();
+        int prevErrors = log.nerrors;
         do {
             Bits uninitsEntry = uninits.dup();
+            uninitsEntry.excludeFrom(nextadr);
             if (tree.cond != null) {
                 scanCond(tree.cond);
                 initsCond = initsWhenFalse;
@@ -883,7 +889,7 @@
             scanStat(tree.body);
             alive |= resolveContinues(tree);
             scan(tree.step);
-            if (log.nerrors != 0 ||
+            if (log.nerrors != prevErrors ||
                 loopPassTwo ||
                 uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
                 break;
@@ -897,8 +903,6 @@
         alive = resolveBreaks(tree, prevPendingExits) ||
             tree.cond != null && !tree.cond.type.isTrue();
         nextadr = nextadrPrev;
-        inits.excludeFrom(nextadr);
-        uninits.excludeFrom(nextadr);
     }
 
     public void visitForeachLoop(JCEnhancedForLoop tree) {
@@ -913,13 +917,15 @@
 
         letInit(tree.pos(), tree.var.sym);
         pendingExits = new ListBuffer<PendingExit>();
+        int prevErrors = log.nerrors;
         do {
             Bits uninitsEntry = uninits.dup();
+            uninitsEntry.excludeFrom(nextadr);
             scanStat(tree.body);
             alive |= resolveContinues(tree);
-            if (log.nerrors != 0 ||
+            if (log.nerrors != prevErrors ||
                 loopPassTwo ||
-                uninitsEntry.diffSet(uninits).nextBit(firstadr) == -1)
+                uninitsEntry.dup().diffSet(uninits).nextBit(firstadr) == -1)
                 break;
             uninits = uninitsEntry.andSet(uninits);
             loopPassTwo = true;
@@ -992,7 +998,6 @@
     public void visitTry(JCTry tree) {
         List<Type> caughtPrev = caught;
         List<Type> thrownPrev = thrown;
-        Map<VarSymbol, JCVariableDecl> unrefdResourcesPrev = unrefdResources;
         thrown = List.nil();
         for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
             List<JCExpression> subClauses = TreeInfo.isMultiCatch(l.head) ?
@@ -1002,17 +1007,18 @@
                 caught = chk.incl(ct.type, caught);
             }
         }
+        ListBuffer<JCVariableDecl> resourceVarDecls = ListBuffer.lb();
         Bits uninitsTryPrev = uninitsTry;
         ListBuffer<PendingExit> prevPendingExits = pendingExits;
         pendingExits = new ListBuffer<PendingExit>();
         Bits initsTry = inits.dup();
         uninitsTry = uninits.dup();
-        unrefdResources = new LinkedHashMap<VarSymbol, JCVariableDecl>();
         for (JCTree resource : tree.resources) {
             if (resource instanceof JCVariableDecl) {
                 JCVariableDecl vdecl = (JCVariableDecl) resource;
                 visitVarDef(vdecl);
-                unrefdResources.put(vdecl.sym, vdecl);
+                unrefdResources.enter(vdecl.sym);
+                resourceVarDecls.append(vdecl);
             } else if (resource instanceof JCExpression) {
                 scanExpr((JCExpression) resource);
             } else {
@@ -1049,11 +1055,14 @@
         Bits uninitsEnd = uninits;
         int nextadrCatch = nextadr;
 
-        if (!unrefdResources.isEmpty() &&
+        if (!resourceVarDecls.isEmpty() &&
                 lint.isEnabled(Lint.LintCategory.TRY)) {
-            for (Map.Entry<VarSymbol, JCVariableDecl> e : unrefdResources.entrySet()) {
-                log.warning(Lint.LintCategory.TRY, e.getValue().pos(),
-                            "try.resource.not.referenced", e.getKey());
+            for (JCVariableDecl resVar : resourceVarDecls) {
+                if (unrefdResources.includes(resVar.sym)) {
+                    log.warning(Lint.LintCategory.TRY, resVar.pos(),
+                                "try.resource.not.referenced", resVar.sym);
+                    unrefdResources.remove(resVar.sym);
+                }
             }
         }
 
@@ -1143,7 +1152,6 @@
             while (exits.nonEmpty()) pendingExits.append(exits.next());
         }
         uninitsTry.andSet(uninitsTryPrev).andSet(uninits);
-        unrefdResources = unrefdResourcesPrev;
     }
 
     public void visitConditional(JCConditional tree) {
@@ -1369,9 +1377,7 @@
     }
 
     void referenced(Symbol sym) {
-        if (unrefdResources != null && unrefdResources.containsKey(sym)) {
-            unrefdResources.remove(sym);
-        }
+        unrefdResources.remove(sym);
     }
 
     public void visitTypeCast(JCTypeCast tree) {
@@ -1430,6 +1436,7 @@
             alive = true;
             this.thrown = this.caught = null;
             this.classDef = null;
+            unrefdResources = new Scope(env.enclClass.sym);
             scan(tree);
         } finally {
             // note that recursive invocations of this method fail hard
@@ -1444,6 +1451,7 @@
             this.make = null;
             this.thrown = this.caught = null;
             this.classDef = null;
+            unrefdResources = null;
         }
     }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Mar 10 20:51:07 2011 -0800
@@ -465,10 +465,9 @@
             // quantify result type with them
             final List<Type> inferredTypes = insttypes.toList();
             final List<Type> all_tvars = tvars; //this is the wrong tvars
-            final MethodType mt2 = new MethodType(mt.argtypes, null, mt.thrown, syms.methodClass);
-            mt2.restype = new ForAll(restvars.toList(), mt.restype) {
+            return new UninferredMethodType(mt, restvars.toList()) {
                 @Override
-                public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
+                List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
                     for (Type t : restundet.toList()) {
                         UndetVar uv = (UndetVar)t;
                         if (uv.qtype == tv) {
@@ -481,21 +480,17 @@
                     }
                     return List.nil();
                 }
-
                 @Override
-                public Type inst(List<Type> inferred, Types types) throws NoInstanceException {
-                    List<Type> formals = types.subst(mt2.argtypes, tvars, inferred);
+                void check(List<Type> inferred, Types types) throws NoInstanceException {
                     // check that actuals conform to inferred formals
-                    checkArgumentsAcceptable(env, capturedArgs, formals, allowBoxing, useVarargs, warn);
+                    checkArgumentsAcceptable(env, capturedArgs, getParameterTypes(), allowBoxing, useVarargs, warn);
                     // check that inferred bounds conform to their bounds
                     checkWithinBounds(all_tvars,
                            types.subst(inferredTypes, tvars, inferred), warn);
                     if (useVarargs) {
-                        chk.checkVararg(env.tree.pos(), formals, msym);
+                        chk.checkVararg(env.tree.pos(), getParameterTypes(), msym);
                     }
-                    return super.inst(inferred, types);
             }};
-            return mt2;
         }
         else {
             // check that actuals conform to inferred formals
@@ -506,6 +501,62 @@
     }
     //where
 
+        /**
+         * A delegated type representing a partially uninferred method type.
+         * The return type of a partially uninferred method type is a ForAll
+         * type - when the return type is instantiated (see Infer.instantiateExpr)
+         * the underlying method type is also updated.
+         */
+        static abstract class UninferredMethodType extends DelegatedType {
+
+            final List<Type> tvars;
+
+            public UninferredMethodType(MethodType mtype, List<Type> tvars) {
+                super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym));
+                this.tvars = tvars;
+                asMethodType().restype = new UninferredReturnType(tvars, mtype.restype);
+            }
+
+            @Override
+            public MethodType asMethodType() {
+                return qtype.asMethodType();
+            }
+
+            @Override
+            public Type map(Mapping f) {
+                return qtype.map(f);
+            }
+
+            void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
+                //update method type with newly inferred type-arguments
+                qtype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
+                                       restype,
+                                       types.subst(UninferredMethodType.this.getThrownTypes(), tvars, inferred),
+                                       UninferredMethodType.this.qtype.tsym);
+                check(inferred, types);
+            }
+
+            abstract void check(List<Type> inferred, Types types) throws NoInstanceException;
+
+            abstract List<Type> getConstraints(TypeVar tv, ConstraintKind ck);
+
+            class UninferredReturnType extends ForAll {
+                public UninferredReturnType(List<Type> tvars, Type restype) {
+                    super(tvars, restype);
+                }
+                @Override
+                public Type inst(List<Type> actuals, Types types) {
+                    Type newRestype = super.inst(actuals, types);
+                    instantiateReturnType(newRestype, actuals, types);
+                    return newRestype;
+                }
+                @Override
+                public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
+                    return UninferredMethodType.this.getConstraints(tv, ck);
+                }
+            }
+        }
+
         private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
                 boolean allowBoxing, boolean useVarargs, Warner warn) {
             try {
@@ -518,25 +569,25 @@
             }
         }
 
-        /** Try to instantiate argument type `that' to given type `to'.
-         *  If this fails, try to insantiate `that' to `to' where
-         *  every occurrence of a type variable in `tvars' is replaced
-         *  by an unknown type.
-         */
-        private Type instantiateArg(ForAll that,
-                                    Type to,
-                                    List<Type> tvars,
-                                    Warner warn) throws InferenceException {
-            List<Type> targs;
-            try {
-                return instantiateExpr(that, to, warn);
-            } catch (NoInstanceException ex) {
-                Type to1 = to;
-                for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
-                    to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
-                return instantiateExpr(that, to1, warn);
-            }
+    /** Try to instantiate argument type `that' to given type `to'.
+     *  If this fails, try to insantiate `that' to `to' where
+     *  every occurrence of a type variable in `tvars' is replaced
+     *  by an unknown type.
+     */
+    private Type instantiateArg(ForAll that,
+                                Type to,
+                                List<Type> tvars,
+                                Warner warn) throws InferenceException {
+        List<Type> targs;
+        try {
+            return instantiateExpr(that, to, warn);
+        } catch (NoInstanceException ex) {
+            Type to1 = to;
+            for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
+                to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
+            return instantiateExpr(that, to1, warn);
         }
+    }
 
     /** check that type parameters are within their bounds.
      */
@@ -616,4 +667,4 @@
                     return t;
                 }
         };
-}
+    }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Mar 10 20:51:07 2011 -0800
@@ -2817,8 +2817,8 @@
                     // local class or this() call
                     thisArg = makeThis(tree.meth.pos(), c.type.getEnclosingType().tsym);
                 } else {
-                    // super() call of nested class
-                    thisArg = makeOwnerThis(tree.meth.pos(), c, false);
+                    // super() call of nested class - never pick 'this'
+                    thisArg = makeOwnerThisN(tree.meth.pos(), c, false);
                 }
                 tree.args = tree.args.prepend(thisArg);
             }
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Mar 10 20:51:07 2011 -0800
@@ -889,10 +889,11 @@
                 : (c.fullname == names.java_lang_Object)
                 ? Type.noType
                 : syms.objectType;
-            ct.supertype_field = supertype;
+            ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
 
             // Determine interfaces.
             ListBuffer<Type> interfaces = new ListBuffer<Type>();
+            ListBuffer<Type> all_interfaces = null; // lazy init
             Set<Type> interfaceSet = new HashSet<Type>();
             List<JCExpression> interfaceTrees = tree.implementing;
             if ((tree.mods.flags & Flags.ENUM) != 0 && target.compilerBootstrap(c)) {
@@ -909,13 +910,22 @@
                 Type i = attr.attribBase(iface, baseEnv, false, true, true);
                 if (i.tag == CLASS) {
                     interfaces.append(i);
+                    if (all_interfaces != null) all_interfaces.append(i);
                     chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
+                } else {
+                    if (all_interfaces == null)
+                        all_interfaces = new ListBuffer<Type>().appendList(interfaces);
+                    all_interfaces.append(modelMissingTypes(i, iface, true));
                 }
             }
-            if ((c.flags_field & ANNOTATION) != 0)
+            if ((c.flags_field & ANNOTATION) != 0) {
                 ct.interfaces_field = List.of(syms.annotationType);
-            else
+                ct.all_interfaces_field = ct.interfaces_field;
+            }  else {
                 ct.interfaces_field = interfaces.toList();
+                ct.all_interfaces_field = (all_interfaces == null)
+                        ? ct.interfaces_field : all_interfaces.toList();
+            }
 
             if (c.fullname == names.java_lang_Object) {
                 if (tree.extending != null) {
@@ -1066,6 +1076,125 @@
         return result;
     }
 
+    Type modelMissingTypes(Type t, final JCExpression tree, final boolean interfaceExpected) {
+        if (t.tag != ERROR)
+            return t;
+
+        return new ErrorType(((ErrorType) t).getOriginalType(), t.tsym) {
+            private Type modelType;
+
+            @Override
+            public Type getModelType() {
+                if (modelType == null)
+                    modelType = new Synthesizer(getOriginalType(), interfaceExpected).visit(tree);
+                return modelType;
+            }
+        };
+    }
+    // where
+    private class Synthesizer extends JCTree.Visitor {
+        Type originalType;
+        boolean interfaceExpected;
+        List<ClassSymbol> synthesizedSymbols = List.nil();
+        Type result;
+
+        Synthesizer(Type originalType, boolean interfaceExpected) {
+            this.originalType = originalType;
+            this.interfaceExpected = interfaceExpected;
+        }
+
+        Type visit(JCTree tree) {
+            tree.accept(this);
+            return result;
+        }
+
+        List<Type> visit(List<? extends JCTree> trees) {
+            ListBuffer<Type> lb = new ListBuffer<Type>();
+            for (JCTree t: trees)
+                lb.append(visit(t));
+            return lb.toList();
+        }
+
+        @Override
+        public void visitTree(JCTree tree) {
+            result = syms.errType;
+        }
+
+        @Override
+        public void visitIdent(JCIdent tree) {
+            if (tree.type.tag != ERROR) {
+                result = tree.type;
+            } else {
+                result = synthesizeClass(tree.name, syms.unnamedPackage).type;
+            }
+        }
+
+        @Override
+        public void visitSelect(JCFieldAccess tree) {
+            if (tree.type.tag != ERROR) {
+                result = tree.type;
+            } else {
+                Type selectedType;
+                boolean prev = interfaceExpected;
+                try {
+                    interfaceExpected = false;
+                    selectedType = visit(tree.selected);
+                } finally {
+                    interfaceExpected = prev;
+                }
+                ClassSymbol c = synthesizeClass(tree.name, selectedType.tsym);
+                result = c.type;
+            }
+        }
+
+        @Override
+        public void visitTypeApply(JCTypeApply tree) {
+            if (tree.type.tag != ERROR) {
+                result = tree.type;
+            } else {
+                ClassType clazzType = (ClassType) visit(tree.clazz);
+                if (synthesizedSymbols.contains(clazzType.tsym))
+                    synthesizeTyparams((ClassSymbol) clazzType.tsym, tree.arguments.size());
+                final List<Type> actuals = visit(tree.arguments);
+                result = new ErrorType(tree.type, clazzType.tsym) {
+                    @Override
+                    public List<Type> getTypeArguments() {
+                        return actuals;
+                    }
+                };
+            }
+        }
+
+        ClassSymbol synthesizeClass(Name name, Symbol owner) {
+            int flags = interfaceExpected ? INTERFACE : 0;
+            ClassSymbol c = new ClassSymbol(flags, name, owner);
+            c.members_field = new Scope.ErrorScope(c);
+            c.type = new ErrorType(originalType, c) {
+                @Override
+                public List<Type> getTypeArguments() {
+                    return typarams_field;
+                }
+            };
+            synthesizedSymbols = synthesizedSymbols.prepend(c);
+            return c;
+        }
+
+        void synthesizeTyparams(ClassSymbol sym, int n) {
+            ClassType ct = (ClassType) sym.type;
+            Assert.check(ct.typarams_field.isEmpty());
+            if (n == 1) {
+                TypeVar v = new TypeVar(names.fromString("T"), sym, syms.botType);
+                ct.typarams_field = ct.typarams_field.prepend(v);
+            } else {
+                for (int i = n; i > 0; i--) {
+                    TypeVar v = new TypeVar(names.fromString("T" + i), sym, syms.botType);
+                    ct.typarams_field = ct.typarams_field.prepend(v);
+                }
+            }
+        }
+    }
+
+
 /* ***************************************************************************
  * tree building
  ****************************************************************************/
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Mar 10 20:51:07 2011 -0800
@@ -45,7 +45,9 @@
 import javax.lang.model.element.ElementVisitor;
 
 import java.util.Map;
+import java.util.Set;
 import java.util.HashMap;
+import java.util.HashSet;
 
 /** Helper class for name resolution, used mostly by the attribution phase.
  *
@@ -896,7 +898,8 @@
                           bestSoFar,
                           allowBoxing,
                           useVarargs,
-                          operator);
+                          operator,
+                          new HashSet<TypeSymbol>());
     }
     // where
     private Symbol findMethod(Env<AttrContext> env,
@@ -909,11 +912,13 @@
                               Symbol bestSoFar,
                               boolean allowBoxing,
                               boolean useVarargs,
-                              boolean operator) {
+                              boolean operator,
+                              Set<TypeSymbol> seen) {
         for (Type ct = intype; ct.tag == CLASS || ct.tag == TYPEVAR; ct = types.supertype(ct)) {
             while (ct.tag == TYPEVAR)
                 ct = ct.getUpperBound();
             ClassSymbol c = (ClassSymbol)ct.tsym;
+            if (!seen.add(c)) return bestSoFar;
             if ((c.flags() & (ABSTRACT | INTERFACE | ENUM)) == 0)
                 abstractok = false;
             for (Scope.Entry e = c.members().lookup(name);
@@ -942,7 +947,7 @@
                     bestSoFar = findMethod(env, site, name, argtypes,
                                            typeargtypes,
                                            l.head, abstractok, bestSoFar,
-                                           allowBoxing, useVarargs, operator);
+                                           allowBoxing, useVarargs, operator, seen);
                 }
                 if (concrete != bestSoFar &&
                     concrete.kind < ERR  && bestSoFar.kind < ERR &&
@@ -1736,24 +1741,26 @@
      */
     Symbol resolveSelfContaining(DiagnosticPosition pos,
                                  Env<AttrContext> env,
-                                 Symbol member) {
+                                 Symbol member,
+                                 boolean isSuperCall) {
         Name name = names._this;
-        Env<AttrContext> env1 = env;
+        Env<AttrContext> env1 = isSuperCall ? env.outer : env;
         boolean staticOnly = false;
-        while (env1.outer != null) {
-            if (isStatic(env1)) staticOnly = true;
-            if (env1.enclClass.sym.isSubClass(member.owner, types) &&
-                isAccessible(env, env1.enclClass.sym.type, member)) {
-                Symbol sym = env1.info.scope.lookup(name).sym;
-                if (sym != null) {
-                    if (staticOnly) sym = new StaticError(sym);
-                    return access(sym, pos, env.enclClass.sym.type,
-                                  name, true);
+        if (env1 != null) {
+            while (env1 != null && env1.outer != null) {
+                if (isStatic(env1)) staticOnly = true;
+                if (env1.enclClass.sym.isSubClass(member.owner, types)) {
+                    Symbol sym = env1.info.scope.lookup(name).sym;
+                    if (sym != null) {
+                        if (staticOnly) sym = new StaticError(sym);
+                        return access(sym, pos, env.enclClass.sym.type,
+                                      name, true);
+                    }
                 }
+                if ((env1.enclClass.sym.flags() & STATIC) != 0)
+                    staticOnly = true;
+                env1 = env1.outer;
             }
-            if ((env1.enclClass.sym.flags() & STATIC) != 0)
-                staticOnly = true;
-            env1 = env1.outer;
         }
         log.error(pos, "encl.class.required", member);
         return syms.errSymbol;
@@ -1764,9 +1771,13 @@
      * JLS2 8.8.5.1 and 15.9.2
      */
     Type resolveImplicitThis(DiagnosticPosition pos, Env<AttrContext> env, Type t) {
+        return resolveImplicitThis(pos, env, t, false);
+    }
+
+    Type resolveImplicitThis(DiagnosticPosition pos, Env<AttrContext> env, Type t, boolean isSuperCall) {
         Type thisType = (((t.tsym.owner.kind & (MTH|VAR)) != 0)
                          ? resolveSelf(pos, env, t.getEnclosingType().tsym, names._this)
-                         : resolveSelfContaining(pos, env, t.tsym)).type;
+                         : resolveSelfContaining(pos, env, t.tsym, isSuperCall)).type;
         if (env.info.isSelfCall && thisType.tsym == env.enclClass.sym)
             log.error(pos, "cant.ref.before.ctor.called", "this");
         return thisType;
--- a/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Thu Mar 10 20:51:07 2011 -0800
@@ -44,13 +44,13 @@
 public class CacheFSInfo extends FSInfo {
 
     /**
-     * Register a Context.Factory to create a singleton CacheFSInfo.
+     * Register a Context.Factory to create a CacheFSInfo.
      */
-    public static void preRegister(final Context context) {
+    public static void preRegister(Context context) {
         context.put(FSInfo.class, new Context.Factory<FSInfo>() {
-            public FSInfo make() {
+            public FSInfo make(Context c) {
                 FSInfo instance = new CacheFSInfo();
-                context.put(FSInfo.class, instance);
+                c.put(FSInfo.class, instance);
                 return instance;
             }
         });
--- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Thu Mar 10 20:51:07 2011 -0800
@@ -129,10 +129,10 @@
     /**
      * Register a Context.Factory to create a JavacFileManager.
      */
-    public static void preRegister(final Context context) {
+    public static void preRegister(Context context) {
         context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
-            public JavaFileManager make() {
-                return new JavacFileManager(context, true, null);
+            public JavaFileManager make(Context c) {
+                return new JavacFileManager(c, true, null);
             }
         });
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Thu Mar 10 20:51:07 2011 -0800
@@ -2183,7 +2183,7 @@
                 }
                 currentClassFile = classfile;
                 if (verbose) {
-                    printVerbose("loading", currentClassFile.toString());
+                    log.printVerbose("loading", currentClassFile.toString());
                 }
                 if (classfile.getKind() == JavaFileObject.Kind.CLASS) {
                     filling = true;
@@ -2452,13 +2452,13 @@
                     for (File file : fm.getLocation(SOURCE_PATH)) {
                         path = path.prepend(file);
                     }
-                    printVerbose("sourcepath", path.reverse().toString());
+                    log.printVerbose("sourcepath", path.reverse().toString());
                 } else if (wantSourceFiles) {
                     List<File> path = List.nil();
                     for (File file : fm.getLocation(CLASS_PATH)) {
                         path = path.prepend(file);
                     }
-                    printVerbose("sourcepath", path.reverse().toString());
+                    log.printVerbose("sourcepath", path.reverse().toString());
                 }
                 if (wantClassFiles) {
                     List<File> path = List.nil();
@@ -2468,7 +2468,7 @@
                     for (File file : fm.getLocation(CLASS_PATH)) {
                         path = path.prepend(file);
                     }
-                    printVerbose("classpath",  path.reverse().toString());
+                    log.printVerbose("classpath",  path.reverse().toString());
                 }
             }
         }
@@ -2519,14 +2519,6 @@
             }
         }
 
-    /** Output for "-verbose" option.
-     *  @param key The key to look up the correct internationalized string.
-     *  @param arg An argument for substitution into the output string.
-     */
-    private void printVerbose(String key, CharSequence arg) {
-        log.printNoteLines("verbose." + key, arg);
-    }
-
     /** Output for "-checkclassfile" option.
      *  @param key The key to look up the correct internationalized string.
      *  @param arg An argument for substitution into the output string.
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1447,7 +1447,7 @@
         try {
             writeClassFile(out, c);
             if (verbose)
-                log.printErrLines("verbose.wrote.file", outFile);
+                log.printVerbose("wrote.file", outFile);
             out.close();
             out = null;
         } finally {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Thu Mar 10 20:51:07 2011 -0800
@@ -299,6 +299,13 @@
     protected JavaCompiler delegateCompiler;
 
     /**
+     * Command line options.
+     */
+    protected Options options;
+
+    protected Context context;
+
+    /**
      * Flag set if any annotation processing occurred.
      **/
     protected boolean annotationProcessingOccurred;
@@ -308,11 +315,9 @@
      **/
     protected boolean implicitSourceFilesRead;
 
-    protected Context context;
-
     /** Construct a new compiler using a shared context.
      */
-    public JavaCompiler(final Context context) {
+    public JavaCompiler(Context context) {
         this.context = context;
         context.put(compilerKey, this);
 
@@ -354,7 +359,7 @@
 
         reader.sourceCompleter = this;
 
-        Options options = Options.instance(context);
+        options = Options.instance(context);
 
         verbose       = options.isSet(VERBOSE);
         sourceOutput  = options.isSet(PRINTSOURCE); // used to be -s
@@ -580,7 +585,7 @@
                                       null, List.<JCTree>nil());
         if (content != null) {
             if (verbose) {
-                printVerbose("parsing.started", filename);
+                log.printVerbose("parsing.started", filename);
             }
             if (taskListener != null) {
                 TaskEvent e = new TaskEvent(TaskEvent.Kind.PARSE, filename);
@@ -589,7 +594,7 @@
             Parser parser = parserFactory.newParser(content, keepComments(), genEndPos, lineDebugInfo);
             tree = parser.parseCompilationUnit();
             if (verbose) {
-                printVerbose("parsing.done", Long.toString(elapsed(msec)));
+                log.printVerbose("parsing.done", Long.toString(elapsed(msec)));
             }
         }
 
@@ -676,7 +681,7 @@
             try {
                 new Pretty(out, true).printUnit(env.toplevel, cdef);
                 if (verbose)
-                    printVerbose("wrote.file", outFile);
+                    log.printVerbose("wrote.file", outFile);
             } finally {
                 out.close();
             }
@@ -792,6 +797,11 @@
             throw new AssertionError("attempt to reuse JavaCompiler");
         hasBeenUsed = true;
 
+        // forcibly set the equivalent of -Xlint:-options, so that no further
+        // warnings about command line options are generated from this point on
+        options.put(XLINT_CUSTOM + "-" + LintCategory.OPTIONS.option, "true");
+        options.remove(XLINT_CUSTOM + LintCategory.OPTIONS.option);
+
         start_msec = now();
 
         try {
@@ -857,7 +867,7 @@
 
         if (verbose) {
             elapsed_msec = elapsed(start_msec);
-            printVerbose("total", Long.toString(elapsed_msec));
+            log.printVerbose("total", Long.toString(elapsed_msec));
         }
 
         reportDeferredDiagnostics();
@@ -963,7 +973,6 @@
     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.isSet(PROC, "none")) {
             processAnnotations = false;
         } else if (procEnvImpl == null) {
@@ -1022,7 +1031,6 @@
             // If there are no annotation processors present, and
             // annotation processing is to occur with compilation,
             // emit a warning.
-            Options options = Options.instance(context);
             if (options.isSet(PROC, "only")) {
                 log.warning("proc.proc-only.requested.no.procs");
                 todo.clear();
@@ -1108,9 +1116,13 @@
     }
 
     boolean explicitAnnotationProcessingRequested() {
-        Options options = Options.instance(context);
         return
             explicitAnnotationProcessingRequested ||
+            explicitAnnotationProcessingRequested(options);
+    }
+
+    static boolean explicitAnnotationProcessingRequested(Options options) {
+        return
             options.isSet(PROCESSOR) ||
             options.isSet(PROCESSORPATH) ||
             options.isSet(PROC, "only") ||
@@ -1142,7 +1154,7 @@
         if (verboseCompilePolicy)
             printNote("[attribute " + env.enclClass.sym + "]");
         if (verbose)
-            printVerbose("checking.attribution", env.enclClass.sym);
+            log.printVerbose("checking.attribution", env.enclClass.sym);
 
         if (taskListener != null) {
             TaskEvent e = new TaskEvent(TaskEvent.Kind.ANALYZE, env.toplevel, env.enclClass.sym);
@@ -1508,7 +1520,8 @@
         }
 
     public void reportDeferredDiagnostics() {
-        if (annotationProcessingOccurred
+        if (errorCount() == 0
+                && annotationProcessingOccurred
                 && implicitSourceFilesRead
                 && implicitSourcePolicy == ImplicitSourcePolicy.UNSET) {
             if (explicitAnnotationProcessingRequested())
@@ -1562,14 +1575,6 @@
         Log.printLines(log.noticeWriter, lines);
     }
 
-    /** Output for "-verbose" option.
-     *  @param key The key to look up the correct internationalized string.
-     *  @param arg An argument for substitution into the output string.
-     */
-    protected void printVerbose(String key, Object arg) {
-        log.printNoteLines("verbose." + key, arg);
-    }
-
     /** Print numbers of errors and warnings.
      */
     protected void printCount(String kind, int count) {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -367,7 +367,11 @@
                         || options.isSet(VERSION)
                         || options.isSet(FULLVERSION))
                         return EXIT_OK;
-                    error("err.no.source.files");
+                    if (JavaCompiler.explicitAnnotationProcessingRequested(options)) {
+                        error("err.no.source.files.classes");
+                    } else {
+                        error("err.no.source.files");
+                    }
                     return EXIT_CMDERR;
                 }
             } catch (java.io.FileNotFoundException e) {
--- a/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/OptionName.java	Thu Mar 10 20:51:07 2011 -0800
@@ -88,6 +88,7 @@
     O("-O"),
     XJCOV("-Xjcov"),
     XD("-XD"),
+    AT("@"),
     SOURCEFILE("sourcefile");
 
     public final String optionName;
--- a/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Thu Mar 10 20:51:07 2011 -0800
@@ -168,6 +168,7 @@
         O,
         XJCOV,
         XD,
+        AT,
         SOURCEFILE);
 
     static Set<OptionName> javacFileManagerOptions = EnumSet.of(
@@ -565,12 +566,27 @@
             }
         },
 
+        // This option exists only for the purpose of documenting itself.
+        // It's actually implemented by the CommandLine class.
+        new Option(AT,                   "opt.arg.file",         "opt.AT") {
+            @Override
+            String helpSynopsis() {
+                hasSuffix = true;
+                return super.helpSynopsis();
+            }
+            @Override
+            public boolean process(Options options, String option) {
+                throw new AssertionError
+                    ("the @ flag should be caught by CommandLine.");
+            }
+        },
+
         /*
          * TODO: With apt, the matches method accepts anything if
          * -XclassAsDecls is used; code elsewhere does the lookup to
          * see if the class name is both legal and found.
          *
-         * In apt, the process method adds the candiate class file
+         * In apt, the process method adds the candidate class file
          * name to a separate list.
          */
         new HiddenOption(SOURCEFILE) {
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Mar 10 20:51:07 2011 -0800
@@ -2357,7 +2357,7 @@
 
         List<JCTypeParameter> typarams = typeParametersOpt();
 
-        JCTree extending = null;
+        JCExpression extending = null;
         if (S.token() == EXTENDS) {
             S.nextToken();
             extending = parseType();
--- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Thu Mar 10 20:51:07 2011 -0800
@@ -807,8 +807,6 @@
         final JavaCompiler compiler;
         /** The log for the round. */
         final Log log;
-        /** The number of warnings in the previous round. */
-        final int priorWarnings;
 
         /** The ASTs to be compiled. */
         List<JCCompilationUnit> roots;
@@ -826,10 +824,10 @@
         private Round(Context context, int number, int priorWarnings) {
             this.context = context;
             this.number = number;
-            this.priorWarnings = priorWarnings;
 
             compiler = JavaCompiler.instance(context);
             log = Log.instance(context);
+            log.nwarnings += priorWarnings;
             log.deferDiagnostics = true;
 
             // the following is for the benefit of JavacProcessingEnvironment.getContext()
@@ -904,8 +902,8 @@
         JavaCompiler finalCompiler(boolean errorStatus) {
             try {
                 JavaCompiler c = JavaCompiler.instance(nextContext());
+                c.log.nwarnings += compiler.log.nwarnings;
                 if (errorStatus) {
-                    c.log.nwarnings += priorWarnings + compiler.log.nwarnings;
                     c.log.nerrors += compiler.log.nerrors;
                 }
                 return c;
@@ -1045,7 +1043,7 @@
          * other values are implicitly reset.
          */
         private Context nextContext() {
-            Context next = new Context();
+            Context next = new Context(context);
 
             Options options = Options.instance(context);
             Assert.checkNonNull(options);
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Mar 10 20:51:07 2011 -0800
@@ -1588,14 +1588,6 @@
 compiler.misc.diamond.non.generic=\
     cannot use ''<>'' with non-generic class {0}
 
-# 0: list of type, 1: message segment
-compiler.misc.diamond.invalid.arg=\
-    type argument {0} inferred for {1} is not allowed in this context
-
-# 0: list of type, 1: message segment
-compiler.misc.diamond.invalid.args=\
-    type arguments {0} inferred for {1} are not allowed in this context
-
 # 0: type, 1: list of type
 compiler.misc.explicit.param.do.not.conform.to.bounds=\
     explicit type argument {0} does not conform to declared bound(s) {1}
@@ -1803,8 +1795,8 @@
 compiler.misc.varargs.clash.with=\
     {0} in {1} overrides {2} in {3}
 
-compiler.misc.non.denotable.type=\
-    Non-denotable type {0} not allowed here
+compiler.misc.diamond.and.anon.class=\
+    cannot use ''<>'' with anonymous inner classes
 
 # 0: symbol kind, 1: symbol, 2: symbol, 3: message segment
 compiler.misc.inapplicable.method=\
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/javac.properties	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -146,6 +146,8 @@
     Print information about which annotations a processor is asked to process
 javac.opt.prefer=\
     Specify which file to read when both a source file and class file are found for an implicitly compiled class
+javac.opt.AT=\
+    Read options and filenames from file
 
 ## errors
 
@@ -161,6 +163,8 @@
     invalid target release: {0}
 javac.err.no.source.files=\
     no source files
+javac.err.no.source.files.classes=\
+    no source files or class names
 javac.err.req.arg=\
     {0} requires an argument
 javac.err.invalid.source=\
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Mar 10 20:51:07 2011 -0800
@@ -567,14 +567,14 @@
         public JCModifiers mods;
         public Name name;
         public List<JCTypeParameter> typarams;
-        public JCTree extending;
+        public JCExpression extending;
         public List<JCExpression> implementing;
         public List<JCTree> defs;
         public ClassSymbol sym;
         protected JCClassDecl(JCModifiers mods,
                            Name name,
                            List<JCTypeParameter> typarams,
-                           JCTree extending,
+                           JCExpression extending,
                            List<JCExpression> implementing,
                            List<JCTree> defs,
                            ClassSymbol sym)
@@ -2104,7 +2104,7 @@
         JCClassDecl ClassDef(JCModifiers mods,
                           Name name,
                           List<JCTypeParameter> typarams,
-                          JCTree extending,
+                          JCExpression extending,
                           List<JCExpression> implementing,
                           List<JCTree> defs);
         JCMethodDecl MethodDef(JCModifiers mods,
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Thu Mar 10 20:51:07 2011 -0800
@@ -135,7 +135,7 @@
         JCClassDecl t = (JCClassDecl) node;
         JCModifiers mods = copy(t.mods, p);
         List<JCTypeParameter> typarams = copy(t.typarams, p);
-        JCTree extending = copy(t.extending, p);
+        JCExpression extending = copy(t.extending, p);
         List<JCExpression> implementing = copy(t.implementing, p);
         List<JCTree> defs = copy(t.defs, p);
         return M.at(t.pos).ClassDef(mods, t.name, typarams, extending, implementing, defs);
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Thu Mar 10 20:51:07 2011 -0800
@@ -146,7 +146,7 @@
     public JCClassDecl ClassDef(JCModifiers mods,
                                 Name name,
                                 List<JCTypeParameter> typarams,
-                                JCTree extending,
+                                JCExpression extending,
                                 List<JCExpression> implementing,
                                 List<JCTree> defs)
     {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Context.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Context.java	Thu Mar 10 20:51:07 2011 -0800
@@ -108,7 +108,7 @@
      * instance.
      */
     public static interface Factory<T> {
-        T make();
+        T make(Context c);
     };
 
     /**
@@ -124,6 +124,8 @@
         Object old = ht.put(key, fac);
         if (old != null)
             throw new AssertionError("duplicate context value");
+        checkState(ft);
+        ft.put(key, fac); // cannot be duplicate if unique in ht
     }
 
     /** Set the value for the key in this context. */
@@ -142,7 +144,7 @@
         Object o = ht.get(key);
         if (o instanceof Factory<?>) {
             Factory<?> fac = (Factory<?>)o;
-            o = fac.make();
+            o = fac.make(this);
             if (o instanceof Factory<?>)
                 throw new AssertionError("T extends Context.Factory");
             Assert.check(ht.get(key) == o);
@@ -158,6 +160,20 @@
 
     public Context() {}
 
+    /**
+     * The table of preregistered factories.
+     */
+    private Map<Key<?>,Factory<?>> ft = new HashMap<Key<?>,Factory<?>>();
+
+    public Context(Context prev) {
+        kt.putAll(prev.kt);     // retain all implicit keys
+        ft.putAll(prev.ft);     // retain all factory objects
+        ht.putAll(prev.ft);     // init main table with factories
+    }
+
+    /*
+     * The key table, providing a unique Key<T> for each Class<T>.
+     */
     private Map<Class<?>, Key<?>> kt = new HashMap<Class<?>, Key<?>>();
 
     private <T> Key<T> key(Class<T> clss) {
@@ -198,6 +214,7 @@
     public void clear() {
         ht = null;
         kt = null;
+        ft = null;
     }
 
     private static void checkState(Map<?,?> t) {
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -329,7 +329,6 @@
         printLines(errWriter, localize(key, args));
     }
 
-
     /** Print the text of a message to the noticeWriter stream,
      *  translating newlines appropriately for the platform.
      */
@@ -337,6 +336,14 @@
         printLines(noticeWriter, localize(key, args));
     }
 
+    /**
+     * Print the localized text of a "verbose" message to the
+     * noticeWriter stream.
+     */
+    public void printVerbose(String key, Object... args) {
+        printLines(noticeWriter, localize("verbose." + key, args));
+    }
+
     protected void directError(String key, Object... args) {
         printErrLines(key, args);
         errWriter.flush();
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,8 +92,9 @@
      *     @com.example.foo
      * Omit parens for marker annotations, and omit "value=" when allowed.
      */
+    @Override
     public String toString() {
-        StringBuffer sb = new StringBuffer("@");
+        StringBuilder sb = new StringBuilder("@");
         sb.append(annotation.type.tsym);
 
         ElementValuePair vals[] = elementValues();
@@ -153,6 +154,7 @@
          * Returns a string representation of this pair
          * of the form "name=value".
          */
+        @Override
         public String toString() {
             return meth.name + "=" + value();
         }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,6 @@
 
 import com.sun.tools.javac.code.Attribute;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.TypeTags;
 
 
@@ -114,6 +113,7 @@
      * @return the text of a Java language annotation value expression
      *          whose value is the value of this annotation type element.
      */
+    @Override
     public String toString() {
         ToStringVisitor tv = new ToStringVisitor();
         attr.accept(tv);
@@ -121,8 +121,9 @@
     }
 
     private class ToStringVisitor implements Attribute.Visitor {
-        private final StringBuffer sb = new StringBuffer();
+        private final StringBuilder sb = new StringBuilder();
 
+        @Override
         public String toString() {
             return sb.toString();
         }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,6 @@
 import com.sun.tools.javac.util.Names;
 import com.sun.tools.javac.util.Position;
 
-import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
 
 /**
@@ -147,6 +146,7 @@
     /**
      * Return true if this is a class, not an interface.
      */
+    @Override
     public boolean isClass() {
         return !Modifier.isInterface(getModifiers());
     }
@@ -155,6 +155,7 @@
      * Return true if this is a ordinary class,
      * not an enumeration, exception, an error, or an interface.
      */
+    @Override
     public boolean isOrdinaryClass() {
         if (isEnum() || isInterface() || isAnnotationType()) {
             return false;
@@ -172,6 +173,7 @@
      * Return true if this is an enumeration.
      * (For legacy doclets, return false.)
      */
+    @Override
     public boolean isEnum() {
         return (getFlags() & Flags.ENUM) != 0
                &&
@@ -182,6 +184,7 @@
      * Return true if this is an interface, but not an annotation type.
      * Overridden by AnnotationTypeDocImpl.
      */
+    @Override
     public boolean isInterface() {
         return Modifier.isInterface(getModifiers());
     }
@@ -189,6 +192,7 @@
     /**
      * Return true if this is an exception class
      */
+    @Override
     public boolean isException() {
         if (isEnum() || isInterface() || isAnnotationType()) {
             return false;
@@ -204,6 +208,7 @@
     /**
      * Return true if this is an error class
      */
+    @Override
     public boolean isError() {
         if (isEnum() || isInterface() || isAnnotationType()) {
             return false;
@@ -275,6 +280,7 @@
     /**
      * Return the package that this class is contained in.
      */
+    @Override
     public PackageDoc containingPackage() {
         PackageDocImpl p = env.getPackageDoc(tsym.packge());
         if (p.setDocPath == false) {
@@ -374,6 +380,7 @@
      * Return the qualified name and any type parameters.
      * Each parameter is a type variable with optional bounds.
      */
+    @Override
     public String toString() {
         return classToString(env, tsym, true);
     }
@@ -401,7 +408,7 @@
      * qualified by their enclosing class(es) only.
      */
     static String classToString(DocEnv env, ClassSymbol c, boolean full) {
-        StringBuffer s = new StringBuffer();
+        StringBuilder s = new StringBuilder();
         if (!c.isInner()) {             // if c is not an inner class
             s.append(getClassName(c, full));
         } else {
@@ -449,10 +456,12 @@
      * Return the modifier string for this class. If it's an interface
      * exclude 'abstract' keyword from the modifier string
      */
+    @Override
     public String modifiers() {
         return Modifier.toString(modifierSpecifier());
     }
 
+    @Override
     public int modifierSpecifier() {
         int modifiers = getModifiers();
         return (isInterface() || isAnnotationType())
@@ -1285,6 +1294,7 @@
      * Return the source position of the entity, or null if
      * no position is available.
      */
+    @Override
     public SourcePosition position() {
         if (tsym.sourcefile == null) return null;
         return SourcePositionImpl.make(tsym.sourcefile,
--- a/langtools/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,7 @@
 
 package com.sun.tools.javadoc;
 
+import java.io.DataInputStream;
 import java.io.InputStream;
 import java.io.IOException;
 import java.text.CollationKey;
@@ -33,6 +34,8 @@
 import com.sun.javadoc.*;
 
 import com.sun.tools.javac.util.Position;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * abstract base class of all Doc classes.  Doc item's are representations
@@ -166,51 +169,28 @@
      * Utility for subclasses which read HTML documentation files.
      */
     String readHTMLDocumentation(InputStream input, FileObject filename) throws IOException {
-        int filesize = input.available();
-        byte[] filecontents = new byte[filesize];
-        input.read(filecontents, 0, filesize);
-        input.close();
+        byte[] filecontents = new byte[input.available()];
+        try {
+            DataInputStream dataIn = new DataInputStream(input);
+            dataIn.readFully(filecontents);
+        } finally {
+            input.close();
+        }
         String encoding = env.getEncoding();
         String rawDoc = (encoding!=null)
             ? new String(filecontents, encoding)
             : new String(filecontents);
-        String upper = null;
-        int bodyIdx = rawDoc.indexOf("<body");
-        if (bodyIdx == -1) {
-            bodyIdx = rawDoc.indexOf("<BODY");
-            if (bodyIdx == -1) {
-                upper = rawDoc.toUpperCase();
-                bodyIdx = upper.indexOf("<BODY");
-                if (bodyIdx == -1) {
-                    env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
-                                       "javadoc.Body_missing_from_html_file");
-                    return "";
-                }
-            }
-        }
-        bodyIdx = rawDoc.indexOf('>', bodyIdx);
-        if (bodyIdx == -1) {
-            env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
-                               "javadoc.Body_missing_from_html_file");
+        Pattern bodyPat = Pattern.compile("(?is).*<body\\b[^>]*>(.*)</body\\b.*");
+        Matcher m = bodyPat.matcher(rawDoc);
+        if (m.matches()) {
+            return m.group(1);
+        } else {
+            String key = rawDoc.matches("(?is).*<body\\b.*")
+                    ? "javadoc.End_body_missing_from_html_file"
+                    : "javadoc.Body_missing_from_html_file";
+            env.error(SourcePositionImpl.make(filename, Position.NOPOS, null), key);
             return "";
         }
-        ++bodyIdx;
-        int endIdx = rawDoc.indexOf("</body", bodyIdx);
-        if (endIdx == -1) {
-            endIdx = rawDoc.indexOf("</BODY", bodyIdx);
-            if (endIdx == -1) {
-                if (upper == null) {
-                    upper = rawDoc.toUpperCase();
-                }
-                endIdx = upper.indexOf("</BODY", bodyIdx);
-                if (endIdx == -1) {
-                    env.error(SourcePositionImpl.make(filename, Position.NOPOS, null),
-                                       "javadoc.End_body_missing_from_html_file");
-                    return "";
-                }
-            }
-        }
-        return rawDoc.substring(bodyIdx, endIdx);
     }
 
     /**
@@ -256,6 +236,7 @@
     /**
      * Returns a string representation of this Doc item.
      */
+    @Override
     public String toString() {
         return qualifiedName();
     }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,14 +31,13 @@
 
 import com.sun.tools.javac.util.List;
 
-import java.net.*;
+import java.io.File;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.net.URLClassLoader;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.StringTokenizer;
 
 /**
  * Class creates, controls and invokes doclets.
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -226,7 +226,7 @@
     }
 
     private String makeSignature(boolean full) {
-        StringBuffer result = new StringBuffer();
+        StringBuilder result = new StringBuilder();
         result.append("(");
         for (List<Type> types = sym.type.getParameterTypes(); types.nonEmpty(); ) {
             Type t = types.head;
@@ -251,6 +251,7 @@
     /**
      * Generate a key for sorting.
      */
+    @Override
     CollationKey generateKey() {
         String k = name() + flatSignature() + typeParametersString();
         // ',' and '&' are between '$' and 'a':  normalize to spaces.
@@ -263,6 +264,7 @@
      * Return the source position of the entity, or null if
      * no position is available.
      */
+    @Override
     public SourcePosition position() {
         if (sym.enclClass().sourcefile == null) return null;
         return SourcePositionImpl.make(sym.enclClass().sourcefile,
--- a/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -142,7 +142,7 @@
             return v + (suffix == 'f' || suffix == 'F' ? "" + suffix : "");
         }
         private static String sourceForm(char c) {
-            StringBuffer buf = new StringBuffer(8);
+            StringBuilder buf = new StringBuilder(8);
             buf.append('\'');
             sourceChar(c, buf);
             buf.append('\'');
@@ -152,7 +152,7 @@
             return "0x" + Integer.toString(c & 0xff, 16);
         }
         private static String sourceForm(String s) {
-            StringBuffer buf = new StringBuffer(s.length() + 5);
+            StringBuilder buf = new StringBuilder(s.length() + 5);
             buf.append('\"');
             for (int i=0; i<s.length(); i++) {
                 char c = s.charAt(i);
@@ -161,7 +161,7 @@
             buf.append('\"');
             return buf.toString();
         }
-        private static void sourceChar(char c, StringBuffer buf) {
+        private static void sourceChar(char c, StringBuilder buf) {
             switch (c) {
             case '\b': buf.append("\\b"); return;
             case '\t': buf.append("\\t"); return;
@@ -179,7 +179,7 @@
                 return;
             }
         }
-        private static void unicodeEscape(char c, StringBuffer buf) {
+        private static void unicodeEscape(char c, StringBuilder buf) {
             final String chars = "0123456789abcdef";
             buf.append("\\u");
             buf.append(chars.charAt(15 & (c>>12)));
@@ -201,6 +201,7 @@
     /**
      * Is this Doc item a field (but not an enum constant?
      */
+    @Override
     public boolean isField() {
         return !isEnumConstant();
     }
@@ -209,6 +210,7 @@
      * Is this Doc item an enum constant?
      * (For legacy doclets, return false.)
      */
+    @Override
     public boolean isEnumConstant() {
         return (getFlags() & Flags.ENUM) != 0 &&
                !env.legacyDoclet;
@@ -257,6 +259,7 @@
      * Return the source position of the entity, or null if
      * no position is available.
      */
+    @Override
     public SourcePosition position() {
         if (sym.enclClass().sourcefile == null) return null;
         return SourcePositionImpl.make(sym.enclClass().sourcefile,
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,10 +44,10 @@
         return (JavadocClassReader)instance;
     }
 
-    public static void preRegister(final Context context) {
+    public static void preRegister(Context context) {
         context.put(classReaderKey, new Context.Factory<ClassReader>() {
-            public ClassReader make() {
-                return new JavadocClassReader(context);
+            public ClassReader make(Context c) {
+                return new JavadocClassReader(c);
             }
         });
     }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,10 +48,10 @@
         return (JavadocEnter)instance;
     }
 
-    public static void preRegister(final Context context) {
+    public static void preRegister(Context context) {
         context.put(enterKey, new Context.Factory<Enter>() {
-               public Enter make() {
-                   return new JavadocEnter(context);
+               public Enter make(Context c) {
+                   return new JavadocEnter(c);
                }
         });
     }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,10 +46,10 @@
         return (JavadocMemberEnter)instance;
     }
 
-    public static void preRegister(final Context context) {
+    public static void preRegister(Context context) {
         context.put(memberEnterKey, new Context.Factory<MemberEnter>() {
-               public MemberEnter make() {
-                   return new JavadocMemberEnter(context);
+               public MemberEnter make(Context c) {
+                   return new JavadocMemberEnter(c);
                }
         });
     }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,10 +34,10 @@
  *  @author Neal Gafter
  */
 public class JavadocTodo extends Todo {
-    public static void preRegister(final Context context) {
+    public static void preRegister(Context context) {
         context.put(todoKey, new Context.Factory<Todo>() {
-               public Todo make() {
-                   return new JavadocTodo(context);
+               public Todo make(Context c) {
+                   return new JavadocTodo(c);
                }
         });
     }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/Messager.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,23 +57,23 @@
         return (Messager)instance;
     }
 
-    public static void preRegister(final Context context,
+    public static void preRegister(Context context,
                                    final String programName) {
         context.put(logKey, new Context.Factory<Log>() {
-            public Log make() {
-                return new Messager(context,
+            public Log make(Context c) {
+                return new Messager(c,
                                     programName);
             }
         });
     }
-    public static void preRegister(final Context context,
+    public static void preRegister(Context context,
                                    final String programName,
                                    final PrintWriter errWriter,
                                    final PrintWriter warnWriter,
                                    final PrintWriter noticeWriter) {
         context.put(logKey, new Context.Factory<Log>() {
-            public Log make() {
-                return new Messager(context,
+            public Log make(Context c) {
+                return new Messager(c,
                                     programName,
                                     errWriter,
                                     warnWriter,
@@ -143,11 +143,9 @@
      * if needed.
      */
     private String getString(String key) {
-        ResourceBundle messageRB = this.messageRB;
         if (messageRB == null) {
             try {
-                this.messageRB = messageRB =
-                    ResourceBundle.getBundle(
+                messageRB = ResourceBundle.getBundle(
                           "com.sun.tools.javadoc.resources.javadoc");
             } catch (MissingResourceException e) {
                 throw new Error("Fatal: Resource for javadoc is missing");
@@ -456,8 +454,6 @@
      * Print exit message.
      */
     public void exitNotice() {
-        int nerrors = nerrors();
-        int nwarnings = nwarnings();
         if (nerrors > 0) {
             notice((nerrors > 1) ? "main.errors" : "main.error",
                    "" + nerrors);
--- a/langtools/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,11 @@
 
 package com.sun.tools.javadoc;
 
-
 import com.sun.javadoc.*;
 
-import static com.sun.javadoc.LanguageVersion.*;
-
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.ClassType;
-import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.TypeTags.*;
 
@@ -55,6 +51,7 @@
     /**
      * Return the generic class or interface that declared this type.
      */
+    @Override
     public ClassDoc asClassDoc() {
         return env.getClassDoc((ClassSymbol)type.tsym);
     }
@@ -111,14 +108,17 @@
     // Asking for the "name" of a parameterized type doesn't exactly make
     // sense.  It's a type expression.  Return the name of its generic
     // type.
+    @Override
     public String typeName() {
         return TypeMaker.getTypeName(type, false);
     }
 
+    @Override
     public ParameterizedType asParameterizedType() {
         return this;
     }
 
+    @Override
     public String toString() {
         return parameterizedTypeToString(env, (ClassType)type, true);
     }
@@ -128,7 +128,7 @@
         if (env.legacyDoclet) {
             return TypeMaker.getTypeName(cl, full);
         }
-        StringBuffer s = new StringBuffer();
+        StringBuilder s = new StringBuilder();
         if (cl.getEnclosingType().tag != CLASS) {               // if not an inner class...
             s.append(TypeMaker.getTypeName(cl, full));
         } else {
--- a/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -322,6 +322,7 @@
     /**
      * Do lazy initialization of "documentation" string.
      */
+    @Override
     protected String documentation() {
         if (documentation == null) {
             int cnt = options.length();
@@ -348,6 +349,7 @@
      * Return the source position of the entity, or null if
      * no position is available.
      */
+    @Override
     public SourcePosition position() {
         JavaFileObject path;
         return ((path = getOverviewPath()) == null) ?
--- a/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -358,14 +358,14 @@
 
         String parameters;
 
-        StringBuffer typeId;
+        StringBuilder typeId;
 
         ListBuffer<String> paramList;
 
         ParameterParseMachine(String parameters) {
             this.parameters = parameters;
             this.paramList = new ListBuffer<String>();
-            typeId = new StringBuffer();
+            typeId = new StringBuilder();
         }
 
         public String[] parseParameters() {
@@ -464,6 +464,7 @@
     /**
      * Return the kind of this tag.
      */
+    @Override
     public String kind() {
         return "@see";
     }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/Start.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/Start.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -396,6 +396,10 @@
         boolean ok = root != null;
         if (ok) ok = docletInvoker.start(root);
 
+        Messager docletMessager = Messager.instance0(context);
+        messager.nwarnings += docletMessager.nwarnings;
+        messager.nerrors += docletMessager.nerrors;
+
         // We're done.
         if (compOpts.get("-verbose") != null) {
             tm = System.currentTimeMillis() - tm;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,15 +27,12 @@
 
 import com.sun.javadoc.*;
 
-import static com.sun.javadoc.LanguageVersion.*;
-
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.code.Type.ClassType;
 import com.sun.tools.javac.code.Type.TypeVar;
 import com.sun.tools.javac.code.Type.ArrayType;
-import com.sun.tools.javac.code.Types;
 import com.sun.tools.javac.util.List;
 
 import static com.sun.tools.javac.code.TypeTags.*;
@@ -109,12 +106,13 @@
     public static String getTypeName(Type t, boolean full) {
         switch (t.tag) {
         case ARRAY:
-            StringBuffer dimension = new StringBuffer();
+            StringBuilder s = new StringBuilder();
             while (t.tag == ARRAY) {
-                dimension = dimension.append("[]");
+                s.append("[]");
                 t = ((ArrayType)t).elemtype;
             }
-            return getTypeName(t, full) + dimension;
+            s.insert(0, getTypeName(t, full));
+            return s.toString();
         case CLASS:
             return ClassDocImpl.getClassName((ClassSymbol)t.tsym, full);
         default:
@@ -130,12 +128,13 @@
     static String getTypeString(DocEnv env, Type t, boolean full) {
         switch (t.tag) {
         case ARRAY:
-            StringBuffer dimension = new StringBuffer();
+            StringBuilder s = new StringBuilder();
             while (t.tag == ARRAY) {
-                dimension = dimension.append("[]");
+                s.append("[]");
                 t = env.types.elemtype(t);
             }
-            return getTypeString(env, t, full) + dimension;
+            s.insert(0, getTypeString(env, t, full));
+            return s.toString();
         case CLASS:
             return ParameterizedTypeImpl.
                         parameterizedTypeToString(env, (ClassType)t, full);
@@ -157,7 +156,7 @@
         if (env.legacyDoclet || sym.type.getTypeArguments().isEmpty()) {
             return "";
         }
-        StringBuffer s = new StringBuffer();
+        StringBuilder s = new StringBuilder();
         for (Type t : sym.type.getTypeArguments()) {
             s.append(s.length() == 0 ? "<" : ", ");
             s.append(TypeVariableImpl.typeVarToString(env, (TypeVar)t, full));
@@ -175,7 +174,7 @@
         if (env.legacyDoclet || cl.getTypeArguments().isEmpty()) {
             return "";
         }
-        StringBuffer s = new StringBuffer();
+        StringBuilder s = new StringBuilder();
         for (Type t : cl.getTypeArguments()) {
             s.append(s.length() == 0 ? "<" : ", ");
             s.append(getTypeString(env, t, full));
@@ -213,9 +212,9 @@
          * For example, a two dimensional array of String returns '[][]'.
          */
         public String dimension() {
-            StringBuffer dimension = new StringBuffer();
+            StringBuilder dimension = new StringBuilder();
             for (Type t = arrayType; t.tag == ARRAY; t = env.types.elemtype(t)) {
-                dimension = dimension.append("[]");
+                dimension.append("[]");
             }
             return dimension.toString();
         }
@@ -304,6 +303,7 @@
          *
          * @return name of type including any dimension information.
          */
+        @Override
         public String toString() {
             return qualifiedTypeName() + dimension();
         }
--- a/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -78,14 +78,17 @@
     /**
      * Return the ClassDoc of the erasure of this type variable.
      */
+    @Override
     public ClassDoc asClassDoc() {
         return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
     }
 
+    @Override
     public TypeVariable asTypeVariable() {
         return this;
     }
 
+    @Override
     public String toString() {
         return typeVarToString(env, (TypeVar)type, true);
     }
@@ -96,7 +99,7 @@
      * "extends" clause.  Class names are qualified if "full" is true.
      */
     static String typeVarToString(DocEnv env, TypeVar v, boolean full) {
-        StringBuffer s = new StringBuffer(v.toString());
+        StringBuilder s = new StringBuilder(v.toString());
         List<Type> bounds = getBounds(v, env);
         if (bounds.nonEmpty()) {
             boolean first = true;
--- a/langtools/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@
 
 import com.sun.javadoc.*;
 
-import static com.sun.javadoc.LanguageVersion.*;
-
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Type;
 import com.sun.tools.javac.util.List;
@@ -69,18 +67,24 @@
     /**
      * Return the ClassDoc of the erasure of this wildcard type.
      */
+    @Override
     public ClassDoc asClassDoc() {
         return env.getClassDoc((ClassSymbol)env.types.erasure(type).tsym);
     }
 
+    @Override
     public WildcardType asWildcardType() {
         return this;
     }
 
+    @Override
     public String typeName()            { return "?"; }
+    @Override
     public String qualifiedTypeName()   { return "?"; }
+    @Override
     public String simpleTypeName()      { return "?"; }
 
+    @Override
     public String toString() {
         return wildcardTypeToString(env, (Type.WildcardType)type, true);
     }
@@ -96,7 +100,7 @@
         if (env.legacyDoclet) {
             return TypeMaker.getTypeName(env.types.erasure(wildThing), full);
         }
-        StringBuffer s = new StringBuffer("?");
+        StringBuilder s = new StringBuilder("?");
         List<Type> bounds = getExtendsBounds(wildThing);
         if (bounds.nonEmpty()) {
             s.append(" extends ");
--- a/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -104,7 +104,7 @@
 tag.End_delimiter_missing_for_possible_SeeTag=End Delimiter } missing for possible See Tag in comment string: "{0}"
 tag.Improper_Use_Of_Link_Tag=Missing closing ''}'' character for inline tag: "{0}"
 javadoc.File_Read_Error=Error while reading file {0}
-javadoc.Body_missing_from_html_file=Body tag missing from HTML
+javadoc.Body_missing_from_html_file=Body tag missing from HTML file
 javadoc.End_body_missing_from_html_file=Close body tag missing from HTML file
 javadoc.Multiple_package_comments=Multiple sources of package comments found for package "{0}"
 javadoc.class_not_found=Class {0} not found.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7023703/T7023703neg.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7023703
+ * @summary Valid code doesn't compile
+ * @compile/fail/ref=T7023703neg.out -XDrawDiagnostics T7023703neg.java
+ */
+
+class T7023703neg {
+
+    void testForLoop(boolean cond) {
+        final int bug;
+        final int bug2;
+        for (;cond;) {
+            final int item = 0;
+            bug2 = 1; //error
+        }
+        bug = 0; //ok
+    }
+
+    void testForEachLoop(java.util.Collection<Integer> c) {
+        final int bug;
+        final int bug2;
+        for (Integer i : c) {
+            final int item = 0;
+            bug2 = 1; //error
+        }
+        bug = 0; //ok
+    }
+
+    void testWhileLoop(boolean cond) {
+        final int bug;
+        final int bug2;
+        while (cond) {
+            final int item = 0;
+            bug2 = 1; //error
+        }
+        bug = 0; //ok
+    }
+
+    void testDoWhileLoop(boolean cond) {
+        final int bug;
+        final int bug2;
+        do {
+            final int item = 0;
+            bug2 = 1; //error
+        } while (cond);
+        bug = 0; //ok
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7023703/T7023703neg.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,5 @@
+T7023703neg.java:37:13: compiler.err.var.might.be.assigned.in.loop: bug2
+T7023703neg.java:47:13: compiler.err.var.might.be.assigned.in.loop: bug2
+T7023703neg.java:57:13: compiler.err.var.might.be.assigned.in.loop: bug2
+T7023703neg.java:67:13: compiler.err.var.might.be.assigned.in.loop: bug2
+4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7023703/T7023703pos.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7023703
+ * @summary Valid code doesn't compile
+ * @compile T7023703pos.java
+ */
+
+class T7023703pos {
+
+    void testForLoop() {
+        final int bug;
+        for (;"a".equals("b");) {
+            final int item = 0;
+        }
+        bug = 0; //ok
+    }
+
+    void testForEachLoop(boolean cond, java.util.Collection<Integer> c) {
+        final int bug;
+        for (Integer i : c) {
+            if (cond) {
+                final int item = 0;
+            }
+        }
+        bug = 0; //ok
+    }
+
+    void testWhileLoop() {
+        final int bug;
+        while ("a".equals("b")) {
+            final int item = 0;
+        }
+        bug = 0; //ok
+    }
+
+    void testDoWhileLoop() {
+        final int bug;
+        do {
+            final int item = 0;
+        } while ("a".equals("b"));
+        bug = 0; //ok
+    }
+
+    private static class Inner {
+        private final int a, b, c, d, e;
+
+        public Inner() {
+            a = b = c = d = e = 0;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7024568/T7024568.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+ * @bug 7024568
+ * @summary Very long method resolution causing OOM error
+ * @compile/fail/ref=T7024568.out -XDrawDiagnostics T7024568.java
+ */
+
+class Main {
+    void test(Obj o) {
+        o.test(0, 0, 0, 0, 0, 0, 0, 0, undefined);
+    }
+}
+
+interface Test {
+    public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, String str);
+    public void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, long l);
+}
+
+interface Obj extends Test, A, B, C, D, E {}
+interface A extends Test {}
+interface B extends A, Test {}
+interface C extends A, B, Test {}
+interface D extends A, B, C, Test {}
+interface E extends A, B, C, D, Test {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/7024568/T7024568.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,2 @@
+T7024568.java:32:40: compiler.err.cant.resolve.location: kindname.variable, undefined, , , (compiler.misc.location: kindname.class, Main, null)
+1 error
--- a/langtools/test/tools/javac/AnonStaticMember_2.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/AnonStaticMember_2.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,6 +1,6 @@
 /*
  * @test  /nodynamiccopyright/
- * @bug 4279339
+ * @bug 4279339 6969184
  * @summary Verify that an anonymous class cannot contain a static method.
  * @author maddox
  *
--- a/langtools/test/tools/javac/InterfaceInInner.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/InterfaceInInner.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,6 +1,6 @@
 /*
  * @test  /nodynamiccopyright/
- * @bug 4063740
+ * @bug 4063740 6969184
  * @summary Interfaces may only be declared in top level classes.
  * @author turnidge
  *
--- a/langtools/test/tools/javac/QualifiedNew.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/QualifiedNew.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,6 +1,6 @@
 /*
  * @test  /nodynamiccopyright/
- * @bug 4406966
+ * @bug 4406966 6969184
  * @summary null qualifying inner instance creation should be error.
  * @author gafter
  *
--- a/langtools/test/tools/javac/T6900037.java	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
- * @bug 6900037
- * @summary javac should warn if earlier -source is used and bootclasspath not set
- * @compile T6900037.java
- * @compile -source 1.6 T6900037.java
- * @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.6 T6900037.java
- * @compile -Werror -source 1.6 -Xlint:-options T6900037.java
- */
-
-class T6900037 { }
--- a/langtools/test/tools/javac/T6900037.out	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-- compiler.warn.source.no.bootclasspath: 1.6
-- compiler.err.warnings.and.werror
-1 error
-1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/T7022711.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,20 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7022711
+ * @summary compiler crash in try-with-resources
+ * @compile/fail/ref=T7022711.out -XDrawDiagnostics T7022711.java
+ */
+
+import java.io.*;
+
+class T7022711 {
+    public static void main (String args[]) throws Exception {
+        try (DataInputStream is = new DataInputStream(new FileInputStream("x"))) {
+            while (true) {
+                is.getChar();  // method not found
+            }
+        } catch (EOFException e) {
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/T7022711.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,2 @@
+T7022711.java:14:19: compiler.err.cant.resolve.location.args: kindname.method, getChar, , , (compiler.misc.location.1: kindname.variable, is, java.io.DataInputStream)
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/UnusedResourcesTest.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,250 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7023233
+ * @summary False positive for -Xlint:try with nested try with resources blocks
+ */
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
+import com.sun.tools.javac.util.JCDiagnostic;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+
+public class UnusedResourcesTest {
+
+    enum XlintOption {
+        NONE("none"),
+        TRY("try");
+
+        String opt;
+
+        XlintOption(String opt) {
+            this.opt = opt;
+        }
+
+        String getXlintOption() {
+            return "-Xlint:" + opt;
+        }
+    }
+
+    enum TwrStmt {
+        TWR1("res1"),
+        TWR2("res2"),
+        TWR3("res3");
+
+        final String resourceName;
+
+        private TwrStmt(String resourceName) {
+            this.resourceName = resourceName;
+        }
+    }
+
+    enum SuppressLevel {
+        NONE,
+        SUPPRESS;
+
+        String getSuppressAnno() {
+            return this == SUPPRESS ?
+                "@SuppressWarnings(\"try\")" :
+                "";
+        }
+    }
+
+    enum ResourceUsage {
+        NONE(null),
+        USE_R1(TwrStmt.TWR1),
+        USE_R2(TwrStmt.TWR2),
+        USE_R3(TwrStmt.TWR3);
+
+        TwrStmt stmt;
+
+        private ResourceUsage(TwrStmt stmt) {
+            this.stmt = stmt;
+        }
+
+        String usedResourceName() {
+            return stmt != null ? stmt.resourceName : null;
+        }
+
+        boolean isUsedIn(TwrStmt res, TwrStmt stmt) {
+            return this.stmt == res &&
+                    stmt.ordinal() >= this.stmt.ordinal();
+        }
+
+        String getUsage(TwrStmt stmt) {
+            return this != NONE && stmt.ordinal() >= this.stmt.ordinal() ?
+                "use(" + usedResourceName() + ");" :
+                "";
+        }
+    }
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        String template = "class Resource implements AutoCloseable {\n" +
+                              "public void close() {}\n" +
+                          "}\n" +
+                          "class Test {\n" +
+                              "void use(Resource r) {}\n" +
+                              "#S void test() {\n" +
+                                 "try (Resource #R1 = new Resource()) {\n" +
+                                    "#U1_R1\n" +
+                                    "#U1_R2\n" +
+                                    "#U1_R3\n" +
+                                    "try (Resource #R2 = new Resource()) {\n" +
+                                       "#U2_R1\n" +
+                                       "#U2_R2\n" +
+                                       "#U2_R3\n" +
+                                       "try (Resource #R3 = new Resource()) {\n" +
+                                           "#U3_R1\n" +
+                                           "#U3_R2\n" +
+                                           "#U3_R3\n" +
+                                       "}\n" +
+                                    "}\n" +
+                                 "}\n" +
+                              "}\n" +
+                          "}\n";
+
+        String source;
+
+        public JavaSource(SuppressLevel suppressLevel, ResourceUsage usage1,
+                ResourceUsage usage2, ResourceUsage usage3) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replace("#S", suppressLevel.getSuppressAnno()).
+                    replace("#R1", TwrStmt.TWR1.resourceName).
+                    replace("#R2", TwrStmt.TWR2.resourceName).
+                    replace("#R3", TwrStmt.TWR3.resourceName).
+                    replace("#U1_R1", usage1.getUsage(TwrStmt.TWR1)).
+                    replace("#U1_R2", usage2.getUsage(TwrStmt.TWR1)).
+                    replace("#U1_R3", usage3.getUsage(TwrStmt.TWR1)).
+                    replace("#U2_R1", usage1.getUsage(TwrStmt.TWR2)).
+                    replace("#U2_R2", usage2.getUsage(TwrStmt.TWR2)).
+                    replace("#U2_R3", usage3.getUsage(TwrStmt.TWR2)).
+                    replace("#U3_R1", usage1.getUsage(TwrStmt.TWR3)).
+                    replace("#U3_R2", usage2.getUsage(TwrStmt.TWR3)).
+                    replace("#U3_R3", usage3.getUsage(TwrStmt.TWR3));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+        for (XlintOption xlint : XlintOption.values()) {
+            for (SuppressLevel suppressLevel : SuppressLevel.values()) {
+                for (ResourceUsage usage1 : ResourceUsage.values()) {
+                    for (ResourceUsage usage2 : ResourceUsage.values()) {
+                        for (ResourceUsage usage3 : ResourceUsage.values()) {
+                                test(xlint,
+                                        suppressLevel,
+                                        usage1,
+                                        usage2,
+                                        usage3);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    // Create a single file manager and reuse it for each compile to save time.
+    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+
+    static void test(XlintOption xlint, SuppressLevel suppressLevel, ResourceUsage usage1,
+                ResourceUsage usage2, ResourceUsage usage3) throws Exception {
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        JavaSource source = new JavaSource(suppressLevel, usage1, usage2, usage3);
+        DiagnosticChecker dc = new DiagnosticChecker();
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
+                Arrays.asList(xlint.getXlintOption()), null, Arrays.asList(source));
+        ct.analyze();
+        check(source, xlint, suppressLevel, usage1, usage2, usage3, dc);
+    }
+
+    static void check(JavaSource source, XlintOption xlint, SuppressLevel suppressLevel,
+                ResourceUsage usage1, ResourceUsage usage2, ResourceUsage usage3, DiagnosticChecker dc) {
+
+        ResourceUsage[] usages = { usage1, usage2, usage3 };
+        boolean[] unusedFound = { dc.unused_r1, dc.unused_r2, dc.unused_r3 };
+        boolean[] usedResources = { false, false, false };
+
+        for (TwrStmt res : TwrStmt.values()) {
+            outer: for (TwrStmt stmt : TwrStmt.values()) {
+                for (ResourceUsage usage : usages) {
+                    if (usage.isUsedIn(res, stmt)) {
+                        usedResources[res.ordinal()] = true;
+                        break outer;
+                    }
+                }
+            }
+        }
+
+        for (TwrStmt stmt : TwrStmt.values()) {
+            boolean unused = !usedResources[stmt.ordinal()] &&
+                    xlint == XlintOption.TRY &&
+                    suppressLevel != SuppressLevel.SUPPRESS;
+            if (unused != unusedFound[stmt.ordinal()]) {
+                throw new Error("invalid diagnostics for source:\n" +
+                    source.getCharContent(true) +
+                    "\nOptions: " + xlint.getXlintOption() +
+                    "\nFound unused res1: " + unusedFound[0] +
+                    "\nFound unused res2: " + unusedFound[1] +
+                    "\nFound unused res3: " + unusedFound[2] +
+                    "\nExpected unused res1: " + !usedResources[0] +
+                    "\nExpected unused res2: " + !usedResources[1] +
+                    "\nExpected unused res3: " + !usedResources[2]);
+            }
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean unused_r1 = false;
+        boolean unused_r2 = false;
+        boolean unused_r3 = false;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.WARNING &&
+                    diagnostic.getCode().contains("try.resource.not.referenced")) {
+                String varName = ((JCDiagnostic)diagnostic).getArgs()[0].toString();
+                if (varName.equals(TwrStmt.TWR1.resourceName)) {
+                    unused_r1 = true;
+                } else if (varName.equals(TwrStmt.TWR2.resourceName)) {
+                    unused_r2 = true;
+                } else if (varName.equals(TwrStmt.TWR3.resourceName)) {
+                    unused_r3 = true;
+                }
+            }
+        }
+    }
+}
--- a/langtools/test/tools/javac/api/6557752/T6557752.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/api/6557752/T6557752.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -119,7 +119,7 @@
                 Types types = task.getTypes();
 
                 if (types.asElement(trees.getOriginalType((ErrorType)typeMirror)) != null) {
-                    throw new AssertionError("Ttypes.asElement() error!");
+                    throw new AssertionError("Types.asElement() error!");
                 }
                 foundError = true;
               }
--- a/langtools/test/tools/javac/diags/ArgTypeCompilerFactory.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/diags/ArgTypeCompilerFactory.java	Thu Mar 10 20:51:07 2011 -0800
@@ -34,6 +34,7 @@
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.file.*;
 import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.parser.Token;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.AbstractDiagnosticFormatter.SimpleConfiguration;
@@ -107,8 +108,7 @@
             JavacTaskImpl t = (JavacTaskImpl) tool.getTask(out, fm, null, opts, null, fos);
             Context c = t.getContext();
             ArgTypeMessages.preRegister(c);
-            Options options = Options.instance(c);
-            Log.instance(c).setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
+            ArgTypeJavaCompiler.preRegister(c);
             Boolean ok = t.call();
 
             return ok;
@@ -144,7 +144,7 @@
                 }
             };
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
-            ArgTypeDiagnosticFormatter.preRegister(c);
+            ArgTypeJavaCompiler.preRegister(c);
             ArgTypeMessages.preRegister(c);
             int result = main.compile(args.toArray(new String[args.size()]), c);
 
@@ -170,7 +170,7 @@
 
             Context c = new Context();
             JavacFileManager.preRegister(c); // can't create it until Log has been set up
-            ArgTypeDiagnosticFormatter.preRegister(c);
+            ArgTypeJavaCompiler.preRegister(c);
             ArgTypeMessages.preRegister(c);
             com.sun.tools.javac.main.Main m = new com.sun.tools.javac.main.Main("javac", out);
             int rc = m.compile(args.toArray(new String[args.size()]), c);
@@ -189,17 +189,6 @@
      * arg types.
      */
     static class ArgTypeDiagnosticFormatter extends AbstractDiagnosticFormatter {
-        static void preRegister(final Context context) {
-            context.put(Log.logKey, new Context.Factory<Log>() {
-                public Log make() {
-                    Log log = new Log(context) { };
-                    Options options = Options.instance(context);
-                    log.setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
-                    return log;
-                }
-            });
-
-        }
 
         ArgTypeDiagnosticFormatter(Options options) {
             super(null, new SimpleConfiguration(options,
@@ -246,14 +235,37 @@
     }
 
     /**
+     * Trivial subtype of JavaCompiler to get access to the protected compilerKey field.
+     * The factory is used to ensure that the log is initialized with an instance of
+     * ArgTypeDiagnosticFormatter before we create the required JavaCompiler.
+     */
+    static class ArgTypeJavaCompiler extends JavaCompiler {
+        static void preRegister(Context context) {
+            context.put(compilerKey, new Context.Factory<JavaCompiler>() {
+                public JavaCompiler make(Context c) {
+                    Log log = Log.instance(c);
+                    Options options = Options.instance(c);
+                    log.setDiagnosticFormatter(new ArgTypeDiagnosticFormatter(options));
+                    return new JavaCompiler(c);
+                }
+            });
+        }
+
+        // not used
+        private ArgTypeJavaCompiler() {
+            super(null);
+        }
+    }
+
+    /**
      * Diagnostic formatter which "localizes" a message as a line
      * containing a key, and a possibly empty set of descriptive strings for the
      * arg types.
      */
     static class ArgTypeMessages extends JavacMessages {
-        static void preRegister(final Context c) {
-            c.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
-                public JavacMessages make() {
+        static void preRegister(Context context) {
+            context.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
+                public JavacMessages make(Context c) {
                     return new ArgTypeMessages(c) {
                         @Override
                         public String getLocalizedString(Locale l, String key, Object... args) {
--- a/langtools/test/tools/javac/diags/CheckResourceKeys.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/diags/CheckResourceKeys.java	Thu Mar 10 20:51:07 2011 -0800
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6964768 6964461 6964469 6964487 6964460 6964481
+ * @bug 6964768 6964461 6964469 6964487 6964460 6964481 6980021
  * @summary need test program to validate javac resource bundles
  */
 
--- a/langtools/test/tools/javac/diags/Example.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/diags/Example.java	Thu Mar 10 20:51:07 2011 -0800
@@ -486,7 +486,7 @@
             if (verbose)
                 System.err.println("run_simple: " + opts + " " + files);
 
-            List<String> args = new ArrayList<String>(opts);
+            List<String> args = new ArrayList<String>();
 
             if (out != null && raw)
                 args.add("-XDrawDiagnostics");
@@ -522,10 +522,10 @@
                 super(context);
             }
 
-            static void preRegister(final Context c, final Set<String> keys) {
+            static void preRegister(Context c, final Set<String> keys) {
                 if (keys != null) {
                     c.put(JavacMessages.messagesKey, new Context.Factory<JavacMessages>() {
-                        public JavacMessages make() {
+                        public JavacMessages make(Context c) {
                             return new MessageTracker(c) {
                                 @Override
                                 public String getLocalizedString(Locale l, String key, Object... args) {
--- a/langtools/test/tools/javac/diags/examples.not-yet.txt	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/diags/examples.not-yet.txt	Thu Mar 10 20:51:07 2011 -0800
@@ -70,7 +70,6 @@
 compiler.misc.kindname.type.variable
 compiler.misc.kindname.type.variable.bound
 compiler.misc.kindname.value
-compiler.misc.non.denotable.type
 compiler.misc.no.unique.minimal.instance.exists
 compiler.misc.resume.abort                              # prompt for a response
 compiler.misc.source.unavailable                        # DiagnosticSource
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/diags/examples/DiamondAndAnonClass.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.misc.diamond.and.anon.class
+// key: compiler.err.cant.apply.diamond.1
+
+import java.util.*;
+
+class DiamondAndAnonClass {
+    void m() {
+        List<String> list = new ArrayList<>() {};
+    }
+}
--- a/langtools/test/tools/javac/diags/examples/DiamondInvalidArg.java	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.misc.diamond.invalid.arg
-// key: compiler.misc.diamond
-// key: compiler.err.cant.apply.diamond.1
-
-class DiamondInvalidArg {
-    static class Foo<X extends Number & Comparable<Number>> { }
-    Foo<?> foo = new Foo<>();
-}
--- a/langtools/test/tools/javac/diags/examples/DiamondInvalidArgs.java	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.misc.diamond.invalid.args
-// key: compiler.misc.diamond
-// key: compiler.err.cant.apply.diamond.1
-
-class DiamondInvalidArgs {
-    static class Foo<X extends Number & Comparable<Number>,
-                           Y extends Number & Comparable<Number>> { }
-    Foo<?,?> foo = new Foo<>();
-}
--- a/langtools/test/tools/javac/generics/6969184/T6969184.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/6969184/T6969184.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6956758
+ * @bug 6969184
  *
  * @summary  poor error recovery after symbol not found
  * @author Maurizio Cimadamore
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7015430/T7015430.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,131 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7015430
+ *
+ * @summary  Incorrect thrown type determined for unchecked invocations
+ * @author Daniel Smith
+ * @compile/fail/ref=T7015430.out -Xlint:unchecked -XDrawDiagnostics T7015430.java
+ *
+ */
+
+class T7015430 {
+    static <E extends Exception> Iterable<E> empty(Iterable<E> arg) throws E {
+        return null;
+    }
+
+    <E extends Exception> T7015430(Iterable<E> arg) throws E { }
+
+    static <E extends Exception> Iterable<E> empty2(Iterable x) throws E {
+        return null;
+    }
+
+    static class Foo<X extends Exception> {
+        Foo() throws X {}
+    }
+
+    /**
+    * Method invocation, no unchecked
+    * inferred: RuntimeException - should pass
+    */
+    void m1() {
+        Iterable<RuntimeException> i = java.util.Collections.emptyList();
+        empty(i);
+    }
+
+    /**
+    * Method invocation, unchecked, inferred arguments
+    * inferred: Exception - should fail
+    */
+    void m2() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        empty(i);
+    }
+
+    /**
+    * Method invocation, unchecked, explicit arguments
+    * inferred: RuntimeException - should pass
+    */
+    void m3() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        T7015430.<RuntimeException>empty(i);
+    }
+
+    /**
+    * Constructor invocation, no unchecked
+    * inferred: RuntimeException - should pass
+    */
+    void m4() {
+        Iterable<RuntimeException> i = java.util.Collections.emptyList();
+        new T7015430(i);
+    }
+
+    /**
+    * Constructor invocation, unchecked, inferred arguments
+    * inferred: Exception - should fail
+    */
+    void m5() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        new T7015430(i);
+    }
+
+    /**
+    * Constructor invocation, unchecked, explicit arguments
+    * inferred: RuntimeException - should pass
+    */
+    void m6() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        new <RuntimeException>T7015430(i);
+    }
+
+    /**
+    * Method invocation, no unchecked, inferred arguments
+    * inferred: RuntimeException - should pass
+    */
+    void m7() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        Iterable<RuntimeException> e = empty2(i);
+    }
+
+    /**
+    * Method invocation, no unchecked, inferred arguments
+    * inferred: Exception - should fail
+    */
+    void m8() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        empty2(i);
+    }
+
+    /**
+    * Constructor invocation, unchecked, explicit arguments
+    * inferred: RuntimeException - should pass
+    */
+    void m9() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        new <RuntimeException> T7015430(i);
+    }
+
+    /**
+    * Constructor invocation, unchecked, inferred arguments
+    * inferred: Exception - should fail
+    */
+    void m10() {
+        Iterable i = java.util.Collections.EMPTY_LIST;
+        new T7015430(i);
+    }
+
+    /**
+    * Constructor invocation, no unchecked, inferred arguments (diamond)
+    * inferred: RuntimeException - should pass
+    */
+    void m11() {
+        Foo<RuntimeException>  o = new Foo<>();
+    }
+
+    /**
+    * Constructor invocation, no unchecked, inferred arguments (diamond)
+    * inferred: Exception - should fail
+    */
+    void m12() {
+        new Foo<>();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7015430/T7015430.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,19 @@
+T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
+T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
+T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:95:15: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:113:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+T7015430.java:129:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+5 errors
+12 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7020657/T7020657neg.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,23 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7020657 6985719
+ *
+ * @summary  Javac rejects a fairly common idiom with raw override and interfaces
+ * @author Maurizio Cimadamore
+ * @compile/fail/ref=T7020657neg.out -XDrawDiagnostics T7020657neg.java
+ *
+ */
+
+import java.util.*;
+
+class T7020657neg {
+    interface A {
+        int get(List<String> l);
+    }
+
+    interface B  {
+        int get(List<Integer> l);
+    }
+
+    interface C extends A, B { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7020657/T7020657neg.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,2 @@
+T7020657neg.java:22:5: compiler.err.name.clash.same.erasure.no.override: get(java.util.List<java.lang.Integer>), T7020657neg.B, get(java.util.List<java.lang.String>), T7020657neg.A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7020657/T7020657pos.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7020657 6985719
+ *
+ * @summary  Javac rejects a fairly common idiom with raw override and interfaces
+ * @author Robert Field
+ * @compile T7020657pos.java
+ *
+ */
+
+import java.util.*;
+
+class T7020657pos {
+    interface A {
+        int get(List<String> l);
+    }
+
+    interface B  {
+        int get(List<Integer> l);
+    }
+
+    interface C extends A, B {
+        int get(List l);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054neg1.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7022054
+ *
+ * @summary  Invalid compiler error on covariant overriding methods with the same erasure
+ * @compile/fail/ref=T7022054neg1.out -XDrawDiagnostics T7022054neg1.java
+ *
+ */
+
+class T7022054neg1 {
+    static class A {
+        A m(String s) { return null; }
+    }
+    static class B extends A {
+        <X extends String> A m(X s) { return null; }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054neg1.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,2 @@
+T7022054neg1.java:15:30: compiler.err.name.clash.same.erasure.no.override: <X>m(X), T7022054neg1.B, m(java.lang.String), T7022054neg1.A, <X>m(X), T7022054neg1.B
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054neg2.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7022054
+ *
+ * @summary  Invalid compiler error on covariant overriding methods with the same erasure
+ * @compile/fail/ref=T7022054neg2.out -XDrawDiagnostics T7022054neg2.java
+ *
+ */
+
+class T7022054neg2 {
+    static class A {
+        static A m(String s) { return null; }
+    }
+    static class B extends A {
+        static <X extends String> A m(X s) { return null; }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054neg2.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,2 @@
+T7022054neg2.java:15:37: compiler.err.name.clash.same.erasure.no.hide: <X>m(X), T7022054neg2.B, m(java.lang.String), T7022054neg2.A
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos1.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7022054
+ *
+ * @summary  Invalid compiler error on covariant overriding methods with the same erasure
+ * @compile T7022054pos1.java
+ *
+ */
+
+class T7022054pos1 {
+    static class A {
+        A m(String s) { return null; }
+    }
+    static class B extends A {
+        <X extends B> X m(String s) { return null; }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/7022054/T7022054pos2.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7022054
+ *
+ * @summary  Invalid compiler error on covariant overriding methods with the same erasure
+ * @compile T7022054pos2.java
+ *
+ */
+
+class T7022054pos2 {
+    static class A {
+        static A m(String s) { return null; }
+    }
+    static class B extends A {
+        static <X extends B> X m(String s) { return null; }
+    }
+}
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6996914
+ * @bug 6996914 7020044
  * @summary  Diamond inference: problem when accessing protected constructor
  * @run main T6996914a
  */
@@ -53,17 +53,6 @@
         }
     }
 
-    enum DiamondKind {
-        STANDARD("new Foo<>();"),
-        ANON("new Foo<>() {};");
-
-        String expr;
-
-        DiamondKind(String expr) {
-            this.expr = expr;
-        }
-    }
-
     enum ConstructorKind {
         PACKAGE(""),
         PROTECTED("protected"),
@@ -104,14 +93,14 @@
         final static String sourceStub =
                         "#I\n" +
                         "class Test {\n" +
-                        "  Foo<String> fs = #D\n" +
+                        "  Foo<String> fs = new Foo<>();\n" +
                         "}\n";
 
         String source;
 
-        public ClientClass(PackageKind pk, DiamondKind dk) {
+        public ClientClass(PackageKind pk) {
             super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
-            source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr);
+            source = sourceStub.replace("#I", pk.importDecl);
         }
 
         @Override
@@ -123,22 +112,20 @@
     public static void main(String... args) throws Exception {
         for (PackageKind pk : PackageKind.values()) {
             for (ConstructorKind ck : ConstructorKind.values()) {
-                for (DiamondKind dk : DiamondKind.values()) {
-                    compileAndCheck(pk, ck, dk);
-                }
+                    compileAndCheck(pk, ck);
             }
         }
     }
 
-    static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception {
+    static void compileAndCheck(PackageKind pk, ConstructorKind ck) throws Exception {
         FooClass foo = new FooClass(pk, ck);
-        ClientClass client = new ClientClass(pk, dk);
+        ClientClass client = new ClientClass(pk);
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         ErrorListener el = new ErrorListener();
         JavacTask ct = (JavacTask)tool.getTask(null, null, el,
                 null, null, Arrays.asList(foo, client));
         ct.analyze();
-        if (el.errors > 0 == check(pk, ck, dk)) {
+        if (el.errors > 0 == check(pk, ck)) {
             String msg = el.errors > 0 ?
                 "Error compiling files" :
                 "No error when compiling files";
@@ -146,10 +133,9 @@
         }
     }
 
-    static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) {
+    static boolean check(PackageKind pk, ConstructorKind ck) {
         switch (pk) {
-            case A: return ck == ConstructorKind.PUBLIC ||
-                    (ck  == ConstructorKind.PROTECTED && dk == DiamondKind.ANON);
+            case A: return ck == ConstructorKind.PUBLIC;
             case DEFAULT: return ck != ConstructorKind.PRIVATE;
             default: throw new AssertionError("Unknown package kind");
         }
--- a/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6996914
+ * @bug 6996914 7020044
  * @summary  Diamond inference: problem when accessing protected constructor
  * @compile T6996914b.java
  */
@@ -35,5 +35,4 @@
 
 class Test {
     Super<String,Integer> ssi1 = new Super<>(1, "", 2);
-    Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
 }
--- a/langtools/test/tools/javac/generics/diamond/T6939780.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/T6939780.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939780
+ * @bug 6939780 7020044
  *
  * @summary  add a warning to detect diamond sites
  * @author mcimadamore
--- a/langtools/test/tools/javac/generics/diamond/T6939780.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/T6939780.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,3 @@
 T6939780.java:19:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
 T6939780.java:20:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
-T6939780.java:22:28: compiler.warn.diamond.redundant.args: Foo<java.lang.Number>, Foo<java.lang.Number>
-T6939780.java:23:28: compiler.warn.diamond.redundant.args.1: Foo<java.lang.Integer>, Foo<java.lang.Number>
-4 warnings
+2 warnings
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,9 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that diamond fails when inference violates declared bounds
+ *           (basic test with nested class, generic/non-generic constructors)
  * @author mcimadamore
  * @compile/fail/ref=Neg01.out Neg01.java -XDrawDiagnostics
  *
@@ -20,19 +21,9 @@
         Neg01<?> n3 = new Neg01<>("");
         Neg01<? super String> n4 = new Neg01<>("");
 
-        Neg01<String> n5 = new Neg01<>(""){};
-        Neg01<? extends String> n6 = new Neg01<>(""){};
-        Neg01<?> n7 = new Neg01<>(""){};
-        Neg01<? super String> n8 = new Neg01<>(""){};
-
-        Neg01<String> n9 = new Neg01<>("", "");
-        Neg01<? extends String> n10 = new Neg01<>("", "");
-        Neg01<?> n11 = new Neg01<>("", "");
-        Foo<? super String> n12 = new Neg01<>("", "");
-
-        Neg01<String> n13 = new Neg01<>("", ""){};
-        Neg01<? extends String> n14 = new Neg01<>("", ""){};
-        Neg01<?> n15 = new Neg01<>("", ""){};
-        Neg01<? super String> n16 = new Neg01<>("", ""){};
+        Neg01<String> n5 = new Neg01<>("", "");
+        Neg01<? extends String> n6 = new Neg01<>("", "");
+        Neg01<?> n7 = new Neg01<>("", "");
+        Foo<? super String> n8 = new Neg01<>("", "");
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg01.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,29 +1,15 @@
-Neg01.java:18:15: compiler.err.not.within.bounds: java.lang.String, X
-Neg01.java:18:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:19:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg01.java:19:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:20:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:21:15: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg01.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:23:15: compiler.err.not.within.bounds: java.lang.String, X
-Neg01.java:23:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:24:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg01.java:24:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:25:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:26:15: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg01.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:28:15: compiler.err.not.within.bounds: java.lang.String, X
-Neg01.java:28:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:29:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg01.java:29:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:30:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
-Neg01.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:33:15: compiler.err.not.within.bounds: java.lang.String, X
-Neg01.java:33:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:34:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg01.java:34:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:35:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-Neg01.java:36:15: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg01.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
-28 errors
+Neg01.java:19:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:19:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:20:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:20:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:21:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:22:15: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg01.java:22:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:24:15: compiler.err.not.within.bounds: java.lang.String, X
+Neg01.java:24:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:25:15: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg01.java:25:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:26:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:27:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , (compiler.misc.location: kindname.class, Neg01<X>, null)
+Neg01.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+14 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,9 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that diamond fails when inference violates declared bounds
+ *           (test with nested class, qualified/simple type expressions)
  * @author mcimadamore
  * @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics
  *
@@ -21,20 +22,10 @@
         Foo<?> f3 = new Foo<>("");
         Foo<? super String> f4 = new Foo<>("");
 
-        Foo<String> f5 = new Foo<>(""){};
-        Foo<? extends String> f6 = new Foo<>(""){};
-        Foo<?> f7 = new Foo<>(""){};
-        Foo<? super String> f8 = new Foo<>(""){};
-
-        Foo<String> f9 = new Foo<>("", "");
-        Foo<? extends String> f10 = new Foo<>("", "");
-        Foo<?> f11 = new Foo<>("", "");
-        Foo<? super String> f12 = new Foo<>("", "");
-
-        Foo<String> f13 = new Foo<>("", ""){};
-        Foo<? extends String> f14 = new Foo<>("", ""){};
-        Foo<?> f15 = new Foo<>("", ""){};
-        Foo<? super String> f16 = new Foo<>("", ""){};
+        Foo<String> f5 = new Foo<>("", "");
+        Foo<? extends String> f6 = new Foo<>("", "");
+        Foo<?> f7 = new Foo<>("", "");
+        Foo<? super String> f8 = new Foo<>("", "");
     }
 
     void testQualified() {
@@ -43,19 +34,9 @@
         Foo<?> f3 = new Neg02.Foo<>("");
         Foo<? super String> f4 = new Neg02.Foo<>("");
 
-        Foo<String> f5 = new Neg02.Foo<>(""){};
-        Foo<? extends String> f6 = new Neg02.Foo<>(""){};
-        Foo<?> f7 = new Neg02.Foo<>(""){};
-        Foo<? super String> f8 = new Neg02.Foo<>(""){};
-
-        Foo<String> f9 = new Neg02.Foo<>("", "");
-        Foo<? extends String> f10 = new Neg02.Foo<>("", "");
-        Foo<?> f11 = new Neg02.Foo<>("", "");
-        Foo<? super String> f12 = new Neg02.Foo<>("", "");
-
-        Foo<String> f13 = new Neg02.Foo<>("", ""){};
-        Foo<? extends String> f14 = new Neg02.Foo<>("", ""){};
-        Foo<?> f15 = new Neg02.Foo<>("", ""){};
-        Foo<? super String> f16 = new Neg02.Foo<>("", ""){};
+        Foo<String> f5 = new Neg02.Foo<>("", "");
+        Foo<? extends String> f6 = new Neg02.Foo<>("", "");
+        Foo<?> f7 = new Neg02.Foo<>("", "");
+        Foo<? super String> f8 = new Neg02.Foo<>("", "");
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg02.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,57 +1,29 @@
-Neg02.java:19:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:24:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:29:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:34:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:41:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:46:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:51:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:56:13: compiler.err.not.within.bounds: java.lang.String, X
-Neg02.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
-Neg02.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-Neg02.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String, X
-Neg02.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
-56 errors
+Neg02.java:20:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:20:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:21:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:22:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:23:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:23:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:25:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:25:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:26:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:32:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:37:13: compiler.err.not.within.bounds: java.lang.String, X
+Neg02.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, X
+Neg02.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, X
+Neg02.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+28 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,9 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that diamond fails when inference violates declared bounds
+ *           (test with inner class, qualified/simple type expressions)
  * @author mcimadamore
  * @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics
  *
@@ -21,20 +22,10 @@
         Foo<?> f3 = new Foo<>("");
         Foo<? super String> f4 = new Foo<>("");
 
-        Foo<String> f5 = new Foo<>(""){};
-        Foo<? extends String> f6 = new Foo<>(""){};
-        Foo<?> f7 = new Foo<>(""){};
-        Foo<? super String> f8 = new Foo<>(""){};
-
-        Foo<String> f9 = new Foo<>("", "");
-        Foo<? extends String> f10 = new Foo<>("", "");
-        Foo<?> f11 = new Foo<>("", "");
-        Foo<? super String> f12 = new Foo<>("", "");
-
-        Foo<String> f13 = new Foo<>("", ""){};
-        Foo<? extends String> f14 = new Foo<>("", ""){};
-        Foo<?> f15 = new Foo<>("", ""){};
-        Foo<? super String> f16 = new Foo<>("", ""){};
+        Foo<String> f5 = new Foo<>("", "");
+        Foo<? extends String> f6 = new Foo<>("", "");
+        Foo<?> f7 = new Foo<>("", "");
+        Foo<? super String> f8 = new Foo<>("", "");
     }
 
     void testQualified_1() {
@@ -43,20 +34,10 @@
         Foo<?> f3 = new Neg03<U>.Foo<>("");
         Foo<? super String> f4 = new Neg03<U>.Foo<>("");
 
-        Foo<String> f5 = new Neg03<U>.Foo<>(""){};
-        Foo<? extends String> f6 = new Neg03<U>.Foo<>(""){};
-        Foo<?> f7 = new Neg03<U>.Foo<>(""){};
-        Foo<? super String> f8 = new Neg03<U>.Foo<>(""){};
-
-        Foo<String> f9 = new Neg03<U>.Foo<>("", "");
-        Foo<? extends String> f10 = new Neg03<U>.Foo<>("", "");
-        Foo<?> f11 = new Neg03<U>.Foo<>("", "");
-        Foo<? super String> f12 = new Neg03<U>.Foo<>("", "");
-
-        Foo<String> f13 = new Neg03<U>.Foo<>("", ""){};
-        Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){};
-        Foo<?> f15 = new Neg03<U>.Foo<>("", ""){};
-        Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){};
+        Foo<String> f5 = new Neg03<U>.Foo<>("", "");
+        Foo<? extends String> f6 = new Neg03<U>.Foo<>("", "");
+        Foo<?> f7 = new Neg03<U>.Foo<>("", "");
+        Foo<? super String> f8 = new Neg03<U>.Foo<>("", "");
     }
 
     void testQualified_2(Neg03<U> n) {
@@ -65,19 +46,9 @@
         Foo<?> f3 = n.new Foo<>("");
         Foo<? super String> f4 = n.new Foo<>("");
 
-        Foo<String> f5 = n.new Foo<>(""){};
-        Foo<? extends String> f6 = n.new Foo<>(""){};
-        Foo<?> f7 = n.new Foo<>(""){};
-        Foo<? super String> f8 = n.new Foo<>(""){};
-
-        Foo<String> f9 = n.new Foo<>("", "");
-        Foo<? extends String> f10 = n.new Foo<>("", "");
-        Foo<?> f11 = n.new Foo<>("", "");
-        Foo<? super String> f12 = n.new Foo<>("", "");
-
-        Foo<String> f13 = n.new Foo<>("", ""){};
-        Foo<? extends String> f14 = n.new Foo<>("", ""){};
-        Foo<?> f15 = n.new Foo<>("", ""){};
-        Foo<? super String> f16 = n.new Foo<>("", ""){};
+        Foo<String> f5 = n.new Foo<>("", "");
+        Foo<? extends String> f6 = n.new Foo<>("", "");
+        Foo<?> f7 = n.new Foo<>("", "");
+        Foo<? super String> f8 = n.new Foo<>("", "");
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg03.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,85 +1,43 @@
-Neg03.java:19:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:24:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:29:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:34:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:41:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:46:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:20:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:20:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:21:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:22:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:23:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:23:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:25:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:25:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:26:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:27:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:28:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:28:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:32:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:32:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:33:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:33:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:34:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:35:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:35:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:37:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:37:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:38:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:38:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:39:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:40:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:40:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:44:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:44:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:45:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:45:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:46:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:47:13: compiler.err.not.within.bounds: ? super java.lang.String, V
 Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:51:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:56:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:63:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:63:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:64:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:64:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:65:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:66:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:66:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:68:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:68:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:69:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:69:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:70:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:71:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:71:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:73:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:73:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:74:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:74:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:75:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:76:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:76:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:78:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg03.java:78:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:79:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg03.java:79:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:80:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-Neg03.java:81:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg03.java:81:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
-84 errors
+Neg03.java:49:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg03.java:49:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:50:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg03.java:50:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:51:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:52:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg03.java:52:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+42 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,9 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that diamond fails when inference violates declared bounds
+ *           (test with local class, qualified/simple type expressions)
  * @author mcimadamore
  * @compile/fail/ref=Neg04.out Neg04.java -XDrawDiagnostics
  *
@@ -20,19 +21,9 @@
         Foo<?> n3 = new Foo<>("");
         Foo<? super String> n4 = new Foo<>("");
 
-        Foo<String> n5 = new Foo<>(""){};
-        Foo<? extends String> n6 = new Foo<>(""){};
-        Foo<?> n7 = new Foo<>(""){};
-        Foo<? super String> n8 = new Foo<>(""){};
-
-        Foo<String> n9 = new Foo<>("", "");
-        Foo<? extends String> n10 = new Foo<>("", "");
-        Foo<?> n11 = new Foo<>("", "");
-        Foo<? super String> n12 = new Foo<>("", "");
-
-        Foo<String> n13 = new Foo<>("", ""){};
-        Foo<? extends String> n14 = new Foo<>("", ""){};
-        Foo<?> n15 = new Foo<>("", ""){};
-        Foo<? super String> n16 = new Foo<>("", ""){};
+        Foo<String> n5 = new Foo<>("", "");
+        Foo<? extends String> n6 = new Foo<>("", "");
+        Foo<?> n7 = new Foo<>("", "");
+        Foo<? super String> n8 = new Foo<>("", "");
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg04.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,29 +1,15 @@
-Neg04.java:18:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg04.java:18:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:19:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg04.java:19:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:20:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:21:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg04.java:21:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:23:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg04.java:23:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:24:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg04.java:24:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:25:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:26:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg04.java:26:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:28:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg04.java:28:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:29:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg04.java:29:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:30:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:31:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg04.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:33:13: compiler.err.not.within.bounds: java.lang.String, V
-Neg04.java:33:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:34:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
-Neg04.java:34:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:35:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-Neg04.java:36:13: compiler.err.not.within.bounds: ? super java.lang.String, V
-Neg04.java:36:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
-28 errors
+Neg04.java:19:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:24:13: compiler.err.not.within.bounds: java.lang.String, V
+Neg04.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String, V
+Neg04.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String, V
+Neg04.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+14 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,8 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that usage of rare types doesn't cause spurious diamond diagnostics
  * @author mcimadamore
  * @compile/fail/ref=Neg05.out Neg05.java -XDrawDiagnostics
  *
@@ -21,20 +21,10 @@
         Neg05<?>.Foo<?> f3 = new Neg05.Foo<>("");
         Neg05<?>.Foo<? super String> f4 = new Neg05.Foo<>("");
 
-        Neg05<?>.Foo<String> f5 = new Neg05.Foo<>(""){};
-        Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>(""){};
-        Neg05<?>.Foo<?> f7 = new Neg05.Foo<>(""){};
-        Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>(""){};
-
-        Neg05<?>.Foo<String> f9 = new Neg05.Foo<>("", "");
-        Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>("", "");
-        Neg05<?>.Foo<?> f11 = new Neg05.Foo<>("", "");
-        Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>("", "");
-
-        Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){};
-        Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){};
-        Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){};
-        Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){};
+        Neg05<?>.Foo<String> f5 = new Neg05.Foo<>("", "");
+        Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>("", "");
+        Neg05<?>.Foo<?> f7 = new Neg05.Foo<>("", "");
+        Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>("", "");
     }
 
     void testRare_2(Neg05 n) {
@@ -43,19 +33,9 @@
         Neg05<?>.Foo<?> f3 = n.new Foo<>("");
         Neg05<?>.Foo<? super String> f4 = n.new Foo<>("");
 
-        Neg05<?>.Foo<String> f5 = n.new Foo<>(""){};
-        Neg05<?>.Foo<? extends String> f6 = n.new Foo<>(""){};
-        Neg05<?>.Foo<?> f7 = n.new Foo<>(""){};
-        Neg05<?>.Foo<? super String> f8 = n.new Foo<>(""){};
-
-        Neg05<?>.Foo<String> f9 = n.new Foo<>("", "");
-        Neg05<?>.Foo<? extends String> f10 = n.new Foo<>("", "");
-        Neg05<?>.Foo<?> f11 = n.new Foo<>("", "");
-        Neg05<?>.Foo<? super String> f12 = n.new Foo<>("", "");
-
-        Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){};
-        Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){};
-        Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){};
-        Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){};
+        Neg05<?>.Foo<String> f5 = n.new Foo<>("", "");
+        Neg05<?>.Foo<? extends String> f6 = n.new Foo<>("", "");
+        Neg05<?>.Foo<?> f7 = n.new Foo<>("", "");
+        Neg05<?>.Foo<? super String> f8 = n.new Foo<>("", "");
     }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg05.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.out	Thu Mar 10 20:51:07 2011 -0800
@@ -7,43 +7,19 @@
 Neg05.java:22:56: compiler.err.improperly.formed.type.inner.raw.param
 Neg05.java:22:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
 Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
+Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
 Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
+Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
 Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
+Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
 Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
-Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:29:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
-Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:30:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
-Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:31:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
-Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:32:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
-Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:34:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
-Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:35:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
-Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:36:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
-Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:37:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
-Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param
-Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param
-48 errors
+Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
+Neg05.java:31:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:32:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:33:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:34:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:36:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:37:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:38:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:39:45: compiler.err.improperly.formed.type.inner.raw.param
+24 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,21 +1,17 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that diamond works where LHS is supertype of RHS (nilary constructor)
  * @author mcimadamore
  * @compile/fail/ref=Neg06.out Neg06.java -XDrawDiagnostics
  *
  */
 
 class Neg06 {
-   interface ISuperFoo<X> {}
-   interface IFoo<X extends Number> extends ISuperFoo<X> {}
 
    static class CSuperFoo<X> {}
    static class CFoo<X extends Number> extends CSuperFoo<X> {}
 
-   ISuperFoo<String> isf = new IFoo<>() {};
    CSuperFoo<String> csf1 = new CFoo<>();
-   CSuperFoo<String> csf2 = new CFoo<>() {};
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg06.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,4 +1,2 @@
-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
+Neg06.java:16:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
+1 error
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,8 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that diamond works where LHS is supertype of RHS (1-ary constructor)
  * @author mcimadamore
  * @compile/fail/ref=Neg07.out Neg07.java -XDrawDiagnostics
  *
@@ -15,5 +15,4 @@
    }
 
    SuperFoo<String> sf1 = new Foo<>("");
-   SuperFoo<String> sf2 = new Foo<>("") {};
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg07.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,3 +1,2 @@
 Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
-Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
-2 errors
+1 error
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg08.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg08.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,30 +1,15 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 6894753
+ * @bug 7020043 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
- * @author mcimadamore
+ * @summary  Check that diamond is not allowed with non-generic class types
+ * @author R&eacute;mi Forax
  * @compile/fail/ref=Neg08.out Neg08.java -XDrawDiagnostics
  *
  */
 
 class Neg08 {
-    static class Foo<X> {
-        Foo(X x) {  }
-    }
-
-    static class DoubleFoo<X,Y> {
-        DoubleFoo(X x,Y y) {  }
-    }
-
-    static class TripleFoo<X,Y,Z> {
-        TripleFoo(X x,Y y,Z z) {  }
-    }
-
-    Foo<? extends Integer> fi = new Foo<>(1);
-    Foo<?> fw = new Foo<>(fi);
-    Foo<? extends Double> fd = new Foo<>(3.0);
-    DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd);
-    Foo<String> fs = new Foo<>("one");
-    TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs);
+   public static void main(String[] args) {
+     String s = new String<>("foo");
+   }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg08.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg08.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,4 +1,2 @@
-Neg08.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.Foo), (compiler.misc.diamond.invalid.arg: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, (compiler.misc.diamond: Neg08.Foo))
-Neg08.java:27:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.DoubleFoo))
-Neg08.java:29:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.TripleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.TripleFoo))
-3 errors
+Neg08.java:13:27: compiler.err.cant.apply.diamond.1: java.lang.String, (compiler.misc.diamond.non.generic: java.lang.String)
+1 error
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,22 +1,25 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620 6894753
+ * @bug 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
- * @author mcimadamore
+ * @summary  Check that diamond is not allowed with anonymous inner class expressions
+ * @author Maurizio Cimadamore
  * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics
  *
  */
 
 class Neg09 {
-    static class Foo<X extends Number & Comparable<Number>> {}
-    static class DoubleFoo<X extends Number & Comparable<Number>,
-                           Y extends Number & Comparable<Number>> {}
-    static class TripleFoo<X extends Number & Comparable<Number>,
-                           Y extends Number & Comparable<Number>,
-                           Z> {}
+    class Member<X> {}
+
+    static class Nested<X> {}
 
-    Foo<?> fw = new Foo<>();
-    DoubleFoo<?,?> dw = new DoubleFoo<>();
-    TripleFoo<?,?,?> tw = new TripleFoo<>();
+    void testSimple() {
+        Member<?> m1 = new Member<>() {};
+        Nested<?> m2 = new Nested<>() {};
+    }
+
+    void testQualified() {
+        Member<?> m1 = this.new Member<>() {};
+        Nested<?> m2 = new Neg09.Nested<>() {};
+    }
 }
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg09.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,4 +1,5 @@
-Neg09.java:19:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.Foo))
-Neg09.java:20:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.DoubleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.DoubleFoo))
-Neg09.java:21:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.TripleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.TripleFoo))
-3 errors
+Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member)
+Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested)
+Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member)
+Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested)
+4 errors
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg10.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg10.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,8 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that 'complex' diamond can infer type that is too specific
  * @author mcimadamore
  * @compile/fail/ref=Neg10.out Neg10.java -XDrawDiagnostics
  *
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg11.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg11.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,8 +1,8 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that unresolved symbols doesn't cause spurious diamond diagnostics
  * @author mcimadamore
  * @compile/fail/ref=Neg11.out Neg11.java -XDrawDiagnostics
  *
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg12.java	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 7020043
- *
- * @summary  Project Coin: diamond allowed on non-generic type
- * @author R&eacute;mi Forax
- * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics
- *
- */
-
-class DiamondRaw {
-   public static void main(String[] args) {
-     String s = new String<>("foo");
-   }
-}
--- a/langtools/test/tools/javac/generics/diamond/neg/Neg12.out	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Neg12.java:13:27: compiler.err.cant.apply.diamond.1: java.lang.String, (compiler.misc.diamond.non.generic: java.lang.String)
-1 error
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos01.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos01.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  basic test for diamond (generic/non-generic constructors)
  * @author mcimadamore
  * @compile Pos01.java
  * @run main Pos01
@@ -44,20 +44,10 @@
         Pos01<?> p3 = new Pos01<>(1);
         Pos01<? super Integer> p4 = new Pos01<>(1);
 
-        Pos01<Integer> p5 = new Pos01<>(1){};
-        Pos01<? extends Integer> p6 = new Pos01<>(1){};
-        Pos01<?> p7 = new Pos01<>(1){};
-        Pos01<? super Integer> p8 = new Pos01<>(1){};
-
-        Pos01<Integer> p9 = new Pos01<>(1, "");
-        Pos01<? extends Integer> p10 = new Pos01<>(1, "");
-        Pos01<?> p11 = new Pos01<>(1, "");
-        Pos01<? super Integer> p12 = new Pos01<>(1, "");
-
-        Pos01<Integer> p13 = new Pos01<>(1, ""){};
-        Pos01<? extends Integer> p14= new Pos01<>(1, ""){};
-        Pos01<?> p15 = new Pos01<>(1, ""){};
-        Pos01<? super Integer> p16 = new Pos01<>(1, ""){};
+        Pos01<Integer> p5 = new Pos01<>(1, "");
+        Pos01<? extends Integer> p6 = new Pos01<>(1, "");
+        Pos01<?> p7 = new Pos01<>(1, "");
+        Pos01<? super Integer> p8 = new Pos01<>(1, "");
     }
 
     public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos02.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos02.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  basic test for diamond (simple/qualified type-expressions)
  * @author mcimadamore
  * @compile Pos02.java
  * @run main Pos02
@@ -44,20 +44,10 @@
         Foo<?> f3 = new Foo<>(1);
         Foo<? super Integer> f4 = new Foo<>(1);
 
-        Foo<Integer> f5 = new Foo<>(1){};
-        Foo<? extends Integer> f6 = new Foo<>(1){};
-        Foo<?> f7 = new Foo<>(1){};
-        Foo<? super Integer> f8 = new Foo<>(1){};
-
-        Foo<Integer> f9 = new Foo<>(1, "");
-        Foo<? extends Integer> f10 = new Foo<>(1, "");
-        Foo<?> f11 = new Foo<>(1, "");
-        Foo<? super Integer> f12 = new Foo<>(1, "");
-
-        Foo<Integer> f13 = new Foo<>(1, ""){};
-        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
-        Foo<?> f15 = new Foo<>(1, ""){};
-        Foo<? super Integer> f16 = new Foo<>(1, ""){};
+        Foo<Integer> f5 = new Foo<>(1, "");
+        Foo<? extends Integer> f6 = new Foo<>(1, "");
+        Foo<?> f7 = new Foo<>(1, "");
+        Foo<? super Integer> f8 = new Foo<>(1, "");
     }
 
     void testQualified() {
@@ -66,20 +56,10 @@
         Foo<?> f3 = new Pos02.Foo<>(1);
         Foo<? super Integer> f4 = new Pos02.Foo<>(1);
 
-        Foo<Integer> f5 = new Pos02.Foo<>(1){};
-        Foo<? extends Integer> f6 = new Pos02.Foo<>(1){};
-        Foo<?> f7 = new Pos02.Foo<>(1){};
-        Foo<? super Integer> f8 = new Pos02.Foo<>(1){};
-
-        Foo<Integer> f9 = new Pos02.Foo<>(1, "");
-        Foo<? extends Integer> f10 = new Pos02.Foo<>(1, "");
-        Foo<?> f11 = new Pos02.Foo<>(1, "");
-        Foo<? super Integer> f12 = new Pos02.Foo<>(1, "");
-
-        Foo<Integer> f13 = new Pos02.Foo<>(1, ""){};
-        Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){};
-        Foo<?> f15 = new Pos02.Foo<>(1, ""){};
-        Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){};
+        Foo<Integer> f5 = new Pos02.Foo<>(1, "");
+        Foo<? extends Integer> f6 = new Pos02.Foo<>(1, "");
+        Foo<?> f7 = new Pos02.Foo<>(1, "");
+        Foo<? super Integer> f8 = new Pos02.Foo<>(1, "");
     }
 
     public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos03.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos03.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  basic test for diamond (simple/qualified type-expressions, member inner)
  * @author mcimadamore
  * @compile Pos03.java
  * @run main Pos03
@@ -45,20 +45,10 @@
         Foo<?> f3 = new Foo<>(1);
         Foo<? super Integer> f4 = new Foo<>(1);
 
-        Foo<Integer> f5 = new Foo<>(1){};
-        Foo<? extends Integer> f6 = new Foo<>(1){};
-        Foo<?> f7 = new Foo<>(1){};
-        Foo<? super Integer> f8 = new Foo<>(1){};
-
-        Foo<Integer> f9 = new Foo<>(1, "");
-        Foo<? extends Integer> f10 = new Foo<>(1, "");
-        Foo<?> f11 = new Foo<>(1, "");
-        Foo<? super Integer> f12 = new Foo<>(1, "");
-
-        Foo<Integer> f13 = new Foo<>(1, ""){};
-        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
-        Foo<?> f15 = new Foo<>(1, ""){};
-        Foo<? super Integer> f16 = new Foo<>(1, ""){};
+        Foo<Integer> f5 = new Foo<>(1, "");
+        Foo<? extends Integer> f6 = new Foo<>(1, "");
+        Foo<?> f7 = new Foo<>(1, "");
+        Foo<? super Integer> f8 = new Foo<>(1, "");
     }
 
     void testQualified_1() {
@@ -67,20 +57,10 @@
         Foo<?> f3 = new Pos03<U>.Foo<>(1);
         Foo<? super Integer> f4 = new Pos03<U>.Foo<>(1);
 
-        Foo<Integer> f5 = new Pos03<U>.Foo<>(1){};
-        Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1){};
-        Foo<?> f7 = new Pos03<U>.Foo<>(1){};
-        Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1){};
-
-        Foo<Integer> f9 = new Pos03<U>.Foo<>(1, "");
-        Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1, "");
-        Foo<?> f11 = new Pos03<U>.Foo<>(1, "");
-        Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1, "");
-
-        Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){};
-        Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){};
-        Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){};
-        Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){};
+        Foo<Integer> f5 = new Pos03<U>.Foo<>(1, "");
+        Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1, "");
+        Foo<?> f7 = new Pos03<U>.Foo<>(1, "");
+        Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1, "");
     }
 
     void testQualified_2(Pos03<U> p) {
@@ -89,20 +69,10 @@
         Foo<?> f3 = p.new Foo<>(1);
         Foo<? super Integer> f4 = p.new Foo<>(1);
 
-        Foo<Integer> f5 = p.new Foo<>(1){};
-        Foo<? extends Integer> f6 = p.new Foo<>(1){};
-        Foo<?> f7 = p.new Foo<>(1){};
-        Foo<? super Integer> f8 = p.new Foo<>(1){};
-
-        Foo<Integer> f9 = p.new Foo<>(1, "");
-        Foo<? extends Integer> f10 = p.new Foo<>(1, "");
-        Foo<?> f11 = p.new Foo<>(1, "");
-        Foo<? super Integer> f12 = p.new Foo<>(1, "");
-
-        Foo<Integer> f13 = p.new Foo<>(1, ""){};
-        Foo<? extends Integer> f14 = p.new Foo<>(1, ""){};
-        Foo<?> f15 = p.new Foo<>(1, ""){};
-        Foo<? super Integer> f16 = p.new Foo<>(1, ""){};
+        Foo<Integer> f5 = p.new Foo<>(1, "");
+        Foo<? extends Integer> f6 = p.new Foo<>(1, "");
+        Foo<?> f7 = p.new Foo<>(1, "");
+        Foo<? super Integer> f8 = p.new Foo<>(1, "");
     }
 
     public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos04.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos04.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  basic test for diamond (simple/qualified type-expressions, local class)
  * @author mcimadamore
  * @compile Pos04.java
  * @run main Pos04
@@ -44,20 +44,10 @@
         Foo<?> p3 = new Foo<>(1);
         Foo<? super Integer> p4 = new Foo<>(1);
 
-        Foo<Integer> p5 = new Foo<>(1){};
-        Foo<? extends Integer> p6 = new Foo<>(1){};
-        Foo<?> p7 = new Foo<>(1){};
-        Foo<? super Integer> p8 = new Foo<>(1){};
-
-        Foo<Integer> p9 = new Foo<>(1, "");
-        Foo<? extends Integer> p10 = new Foo<>(1, "");
-        Foo<?> p11 = new Foo<>(1, "");
-        Foo<? super Integer> p12 = new Foo<>(1, "");
-
-        Foo<Integer> p13 = new Foo<>(1, ""){};
-        Foo<? extends Integer> p14 = new Foo<>(1, ""){};
-        Foo<?> p15 = new Foo<>(1, ""){};
-        Foo<? super Integer> p16 = new Foo<>(1, ""){};
+        Foo<Integer> p5 = new Foo<>(1, "");
+        Foo<? extends Integer> p6 = new Foo<>(1, "");
+        Foo<?> p7 = new Foo<>(1, "");
+        Foo<? super Integer> p8 = new Foo<>(1, "");
     }
 
     public static void main(String[] args) {
--- a/langtools/test/tools/javac/generics/diamond/pos/Pos05.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos05.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug 6939620
+ * @bug 6939620 7020044
  *
- * @summary  Switch to 'complex' diamond inference scheme
+ * @summary  Check that 'complex' inference sometimes works in method context
  * @author mcimadamore
  * @compile Pos05.java
  *
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos06.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6939620 6894753 7020044
+ *
+ * @summary  Diamond and subtyping
+ * @author mcimadamore
+ * @compile Pos06.java
+ *
+ */
+
+class Pos06 {
+    static class Foo<X> {
+        Foo(X x) {  }
+    }
+
+    static class DoubleFoo<X,Y> {
+        DoubleFoo(X x,Y y) {  }
+    }
+
+    static class TripleFoo<X,Y,Z> {
+        TripleFoo(X x,Y y,Z z) {  }
+    }
+
+    Foo<? extends Integer> fi = new Foo<>(1);
+    Foo<?> fw = new Foo<>(fi);
+    Foo<? extends Double> fd = new Foo<>(3.0);
+    DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd);
+    Foo<String> fs = new Foo<>("one");
+    TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos07.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6939620 6894753 7020044
+ *
+ * @summary  Diamond and intersection types
+ * @author mcimadamore
+ * @compile Pos07.java
+ *
+ */
+
+class Pos07 {
+    static class Foo<X extends Number & Comparable<Number>> {}
+    static class DoubleFoo<X extends Number & Comparable<Number>,
+                           Y extends Number & Comparable<Number>> {}
+    static class TripleFoo<X extends Number & Comparable<Number>,
+                           Y extends Number & Comparable<Number>,
+                           Z> {}
+
+    Foo<?> fw = new Foo<>();
+    DoubleFoo<?,?> dw = new DoubleFoo<>();
+    TripleFoo<?,?,?> tw = new TripleFoo<>();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/inference/T7015715.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7015715
+ *
+ * @summary lub gets stuck on type with complex supertype
+ * @author Neal Gafter
+ * @compile T7015715.java
+ *
+ */
+
+class T7015715 {
+
+    interface I<T> {}
+
+    interface A<T> extends I<A<A<T>>>{}
+
+    static abstract class X {
+       abstract <T> T foo(T x, T y);
+       void bar(A<Integer> x, A<String> y){
+           foo(x, y);
+       }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/implicitThis/6541876/T6541876a.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6541876
+ * @summary  "Enclosing Instance" error new in 1.6
+ *
+ */
+
+public class T6541876a {
+    class X {
+        class Y {}
+    }
+
+    class A extends X {
+        class B extends X.Y {}
+    }
+
+    public static void main(String[] args) {
+        new T6541876a().new A().new B();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/implicitThis/6541876/T6541876b.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 6541876 6569091
+ * @summary  "Enclosing Instance" error new in 1.6
+ *
+ */
+
+public class T6541876b {
+
+    enum ENUM {
+        ENUM_CONST {
+            public AbstractClass method() {
+                return new AbstractClass() {
+                    public boolean method() {
+                        return true;
+                    }
+                };
+            }
+        };
+
+        public abstract AbstractClass method();
+
+        private abstract class AbstractClass {
+            public abstract boolean method();
+        }
+    }
+
+    public static void main(String[] args) {
+        ENUM.ENUM_CONST.method();
+    }
+}
--- a/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed3.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/implicitThis/NewBeforeOuterConstructed3.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
  * @test
  * @bug 4704371 6313120
  * @summary compiler generates unverifiable code for implicit reference to uninit'd this
- * @compile/fail NewBeforeOuterConstructed3.java
  */
 
 public class NewBeforeOuterConstructed3 {
--- a/langtools/test/tools/javac/multicatch/Neg05.java	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6943289
- *
- * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
- * @author mcimadamore
- * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java
- *
- */
-
-class Neg02 {
-
-    static class Foo<X> {
-       Foo(X x) {}
-    }
-
-    static interface Base<X> {}
-    static class A extends Exception implements Base<String> {}
-    static class B extends Exception implements Base<Integer> {}
-
-    void m() {
-        try {
-            if (true) {
-                throw new A();
-            }
-            else {
-                throw new B();
-            }
-        } catch (A | B ex) {
-            Foo<?> f = new Foo<>(ex);
-        }
-    }
-}
--- a/langtools/test/tools/javac/multicatch/Neg05.out	Thu Mar 10 17:11:19 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
-Neg05.java:30:31: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg02.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Exception&Neg02.Base<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, (compiler.misc.diamond: Neg02.Foo))
-1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Pos09.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6943289 7020044
+ *
+ * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
+ * @author mcimadamore
+ * @compile Pos09.java
+ *
+ */
+
+class Pos09 {
+
+    static class Foo<X> {
+       Foo(X x) {}
+    }
+
+    static interface Base<X> {}
+    static class A extends Exception implements Base<String> {}
+    static class B extends Exception implements Base<Integer> {}
+
+    void m() {
+        try {
+            if (true) {
+                throw new A();
+            }
+            else {
+                throw new B();
+            }
+        } catch (A | B ex) {
+            Foo<?> f = new Foo<>(ex);
+        }
+    }
+}
--- a/langtools/test/tools/javac/nested/4903103/T4903103.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/nested/4903103/T4903103.java	Thu Mar 10 20:51:07 2011 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,11 +25,14 @@
  * @test
  * @bug     4903103
  * @summary Can't compile subclasses of inner classes
- * @compile T4903103.java
  */
 
 public class T4903103 {
     private class InnerSuperclass extends T4903103 {}
 
     private class InnerSubclass extends InnerSuperclass {}
+
+    public static void main(String[] args) {
+        new T4903103().new InnerSubclass();
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/options/T6900037.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,34 @@
+/*
+ * 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 6900037
+ * @summary javac should warn if earlier -source is used and bootclasspath not set
+ * @compile T6900037.java
+ * @compile -source 1.6 T6900037.java
+ * @compile/fail/ref=T6900037.out -XDrawDiagnostics -Werror -source 1.6 T6900037.java
+ * @compile -Werror -source 1.6 -Xlint:-options T6900037.java
+ */
+
+class T6900037 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/options/T6900037.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,4 @@
+- compiler.warn.source.no.bootclasspath: 1.6
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/options/T6986895.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6986895
+ * @summary compiler gives misleading message for no input files
+ */
+
+import java.io.*;
+import java.util.*;
+
+public class T6986895 {
+    public static void main(String... args) throws Exception {
+        new T6986895().run();
+    }
+
+    String noSourceFiles = "no source files";
+    String noSourceFilesOrClasses = "no source files or class names";
+
+    void run() throws Exception {
+        Locale prev = Locale.getDefault();
+        try {
+            Locale.setDefault(Locale.ENGLISH);
+            test(noSourceFiles,           "-Werror");
+            test(noSourceFilesOrClasses,  "-Werror", "-Xprint");
+        } finally {
+            Locale.setDefault(prev);
+        }
+    }
+
+    void test(String expect, String... args) throws Exception {
+        System.err.println("Test " + expect + ": " + Arrays.asList(args));
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        System.err.println("compilation failed; rc=" + rc);
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (!out.contains(expect))
+            throw new Exception("expected text not found: " + expect);
+        System.err.println();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/options/T7022337.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 7022337
+ * @summary repeated warnings about bootclasspath not set
+ * @library ../lib
+ * @build JavacTestingAbstractProcessor T7022337
+ * @run main T7022337
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+
+public class T7022337 extends JavacTestingAbstractProcessor {
+    public static void main(String... args) throws Exception {
+        new T7022337().run();
+    }
+
+    void run() throws Exception {
+        String myName = T7022337.class.getSimpleName();
+        File testSrc = new File(System.getProperty("test.src"));
+        File file = new File(testSrc, myName + ".java");
+
+        String out = compile(
+            "-XDrawDiagnostics",
+            "-d", ".",
+            "-processor", myName,
+            "-source", "6", // explicit use of older source value without bootclasspath
+            file.getPath());
+
+        int count = 0;
+        for (String line: out.split("[\r\n]+")) {
+            if (line.contains("compiler.warn.source.no.bootclasspath"))
+                count++;
+        }
+        if (count != 1)
+            throw new Exception("unexpected number of warnings found: " + count + ", expected: 1");
+    }
+
+    String 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.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("compilation failed unexpectedly: rc=" + rc);
+        return out;
+    }
+
+    // ----------
+
+    int round = 0;
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+
+        final int MAXROUNDS = 3;
+        if (round < MAXROUNDS)
+            generate("Gen" + round);
+
+        return true;
+    }
+
+    void generate(String name) {
+        try {
+            JavaFileObject fo = filer.createSourceFile(name);
+            Writer out = fo.openWriter();
+            try {
+                out.write("class " + name + " { }");
+            } finally {
+                out.close();
+            }
+        } catch (IOException e) {
+            throw new Error(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/TestWarnErrorCount.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,340 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 7022337
+ * @summary repeated warnings about bootclasspath not set
+ * @library ../lib
+ * @build JavacTestingAbstractProcessor TestWarnErrorCount
+ * @run main TestWarnErrorCount
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+
+@SupportedOptions({"errKind", "msgrWarnKind", "javaWarnKind"})
+public class TestWarnErrorCount extends JavacTestingAbstractProcessor {
+    public static void main(String... args) throws Exception {
+        new TestWarnErrorCount().run(args);
+    }
+
+    final int MAX_GEN = 10;
+    final int ERROR_ROUND = MAX_GEN / 2; // when to generate error
+
+    /**
+     * Type of errors to generate in test case.
+     */
+    enum ErrorKind {
+        /** No errors. */
+        NONE,
+        /** Source code errors. */
+        JAVA,
+        /** Errors reported to Messager. */
+        MESSAGER,
+        /** Error as a result of using -Werror. */
+        WERROR,
+    }
+
+    /**
+     * Frequency of warnings in test case.
+     */
+    enum WarnKind {
+        /** No warnings. */
+        NONE {
+            boolean warn(int round) { return false; }
+            int count(int start, int end) { return 0; }
+        },
+        /** Generate a warning if round count is a multiple of 2. */
+        EVERY_TWO {
+            boolean warn(int round) { return (round % 2) == 0; }
+            int count(int start, int end) { return (end / 2) - ((start - 1)/ 2); }
+        },
+        /** Generate a warning if round count is a multiple of 3. */
+        EVERY_THREE {
+            boolean warn(int round) { return (round % 3) == 0; }
+            int count(int start, int end) { return (end / 3) - ((start - 1)/ 3); }
+        },
+        /** Generate a warning every round. */
+        ALL {
+            boolean warn(int round) { return true; }
+            int count(int start, int end) { return (end - start + 1); }
+        };
+
+        /** whether to generate a warning in round 'round'. */
+        abstract boolean warn(int round);
+
+        /** number of warnings generated in a range of rounds, inclusive. */
+        abstract int count(int start, int end);
+    }
+
+
+    /**
+     * Run test.
+     * @param args provide ability to specify particular test cases for debugging.
+     */
+    void run(String... args) throws Exception {
+        for (String arg: args) {
+            if (arg.matches("[0-9]+")) {
+                if (testCases == null)
+                    testCases = new HashSet<Integer>();
+                testCases.add(Integer.valueOf(arg));
+            } else if (arg.equals("-stopOnError")) {
+                stopOnError = true;
+            } else
+                throw new IllegalArgumentException(arg);
+        }
+
+        run ();
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    /**
+     * Run test.
+     */
+    void run() throws Exception {
+        for (ErrorKind ek: ErrorKind.values()) {
+            for (WarnKind mwk: WarnKind.values()) {
+                for (WarnKind jwk: WarnKind.values()) {
+                    test(ek, mwk, jwk);
+                    if (stopOnError && errors > 0)
+                        throw new Exception(errors + " errors found");
+                }
+            }
+        }
+    }
+
+    boolean stopOnError;
+    Set<Integer> testCases;
+    int testNum = 0;
+
+    /**
+     * Run a test case.
+     * @param ek    The type of errors to generate
+     * @param mwk   The frequency of Messager warnings to generate
+     * @param jwk   The frequency of Java warnings to generate
+     */
+    void test(ErrorKind ek, WarnKind mwk, WarnKind jwk) {
+        testNum++;
+
+        if (testCases != null && !testCases.contains(testNum))
+            return;
+
+        System.err.println("Test " + testNum + ": ek:" + ek + " mwk:" + mwk + " jwk:" + jwk);
+
+        File testDir = new File("test" + testNum);
+        testDir.mkdirs();
+
+        String myName = TestWarnErrorCount.class.getSimpleName();
+        File testSrc = new File(System.getProperty("test.src"));
+        File file = new File(testSrc, myName + ".java");
+
+        List<String> args = new ArrayList<String>();
+        args.addAll(Arrays.asList(
+            "-XDrawDiagnostics",
+            "-d", testDir.getPath(),
+            "-processor", myName,
+//            "-XprintRounds",
+            "-Xlint:all,-path",
+            "-AerrKind=" + ek,
+            "-AmsgrWarnKind=" + mwk,
+            "-AjavaWarnKind=" + jwk));
+        if (ek == ErrorKind.WERROR)
+            args.add("-Werror");
+        args.add(file.getPath());
+
+        String out = compile(args.toArray(new String[args.size()]));
+
+        int errsFound = 0;
+        int errsReported = 0;
+        int warnsFound = 0;
+        int warnsReported = 0;
+
+        // Scan the output looking for messages of interest.
+
+        for (String line: out.split("[\r\n]+")) {
+            if (line.contains("compiler.err.")) {
+                errsFound++;
+            } else if (line.contains("compiler.warn.")) {
+                warnsFound++;
+            } else if (line.matches("[0-9]+ error(?:s?)")) {
+                errsReported = Integer.valueOf(line.substring(0, line.indexOf("error")).trim());
+            } else if (line.matches("[0-9]+ warning(?:s?)")) {
+                warnsReported = Integer.valueOf(line.substring(0, line.indexOf("warning")).trim());
+            }
+        }
+
+        // Compute the expected number of errors and warnings, based on
+        // the test case parameters.
+        // This is highly specific to the annotation processor below, and to
+        // the files it generates.
+        // Generally, the rules are:
+        // -- errors stop annotation processing, allowing for one extra "last round"
+        // -- messager warnings are immediate
+        // -- javac warnings are not shown before the final compilation
+        //      (FIXME?  -Werror does not stop processing for java warnings)
+        int errsExpected;
+        int msgrWarnsExpected;
+        int javaWarnsExpected;
+        switch (ek) {
+            case NONE:
+                errsExpected = 0;
+                msgrWarnsExpected = mwk.count(1, 1 + MAX_GEN + 1);
+                javaWarnsExpected = jwk.count(2, 1 + MAX_GEN);
+                break;
+            case MESSAGER:
+                errsExpected = 1;
+                msgrWarnsExpected = mwk.count(1, ERROR_ROUND + 1);
+                javaWarnsExpected = 0;
+                break;
+            case JAVA:
+                errsExpected = 2;
+                msgrWarnsExpected = mwk.count(1, ERROR_ROUND + 1);
+                javaWarnsExpected = 0;
+                break;
+            case WERROR:
+                errsExpected = (mwk != WarnKind.NONE || jwk != WarnKind.NONE) ? 1 : 0;
+                switch (mwk) {
+                    case NONE:
+                        msgrWarnsExpected = 0;
+                        javaWarnsExpected = (jwk == WarnKind.NONE)
+                                ? 0
+                                : 1;  // this is surprising: javac only reports warning in first file
+                        break;
+                    case EVERY_TWO:
+                        msgrWarnsExpected = mwk.count(1, 2 + 1);
+                        javaWarnsExpected = 0;
+                        break;
+                    case EVERY_THREE:
+                        msgrWarnsExpected = mwk.count(1, 3 + 1);
+                        javaWarnsExpected = 0;
+                        break;
+                    case ALL:
+                        msgrWarnsExpected = mwk.count(1, 1 + 1);
+                        javaWarnsExpected = 0;
+                        break;
+                    default:
+                        throw new IllegalStateException();
+                }
+                break;
+            default:
+                throw new IllegalStateException();
+        }
+
+        int warnsExpected = msgrWarnsExpected + javaWarnsExpected;
+        System.err.println("mwk: " + msgrWarnsExpected
+                + ", jwk: " + javaWarnsExpected
+                + ", total: " + warnsExpected);
+
+        boolean ok;
+        ok  = checkEqual("errors", "reported", errsFound, errsReported);
+        ok &= checkEqual("errors", "expected", errsFound, errsExpected);
+        ok &= checkEqual("warnings", "reported", warnsFound, warnsReported);
+        ok &= checkEqual("warnings", "expected", warnsFound, warnsExpected);
+        if (ok)
+            System.err.println("OK");
+
+        System.err.println();
+    }
+
+    String compile(String... 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.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            System.err.println("compilation failed: rc=" + rc);
+        return out;
+    }
+
+    boolean checkEqual(String l1, String l2, int i1, int i2) {
+        if (i1 != i2)
+            error("number of " + l1 + " found, " + i1 + ", does not match number " + l2 + ", " + i2);
+        return (i1 == i2);
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors = 0;
+
+    // ----- Annotation processor -----
+
+    int round = 0;
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+
+        ErrorKind ek = ErrorKind.valueOf(options.get("errKind"));
+        WarnKind mwk = WarnKind.valueOf(options.get("msgrWarnKind"));
+        WarnKind jwk = WarnKind.valueOf(options.get("javaWarnKind"));
+        messager.printMessage(Diagnostic.Kind.NOTE,
+                "Round " + round
+                + " " + roundEnv.getRootElements()
+                + ", last round: " + roundEnv.processingOver());
+        messager.printMessage(Diagnostic.Kind.NOTE,
+                "ek: " + ek + ", mwk: " + mwk + ", jwk: " + jwk);
+
+        if (round <= MAX_GEN && !roundEnv.processingOver())
+            generate("Gen" + round,
+                    (ek == ErrorKind.JAVA) && (round == ERROR_ROUND),
+                    jwk.warn(round));
+
+        if (mwk.warn(round))
+            messager.printMessage(Diagnostic.Kind.WARNING, "round " + round);
+
+        if ((ek == ErrorKind.MESSAGER) && (round == ERROR_ROUND))
+            messager.printMessage(Diagnostic.Kind.ERROR, "round " + round);
+
+        return true;
+    }
+
+    void generate(String name, boolean error, boolean warn) {
+        try {
+            JavaFileObject fo = filer.createSourceFile(name);
+            Writer out = fo.openWriter();
+            try {
+                out.write("class " + name + " {\n"
+                        + (warn ? "    int i = (int) 0;\n" : "")
+                        + (error ? "   ERROR\n" : "")
+                        + "}\n");
+            } finally {
+                out.close();
+            }
+        } catch (IOException e) {
+            throw new Error(e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/TestSymtabItems.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,221 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7021183
+ * @summary 269: assertion failure getting enclosing element of an undefined name
+ */
+
+import java.lang.reflect.Field;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.PackageElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.element.TypeParameterElement;
+import javax.lang.model.element.UnknownElementException;
+import javax.lang.model.element.VariableElement;
+import javax.lang.model.type.TypeMirror;
+import javax.lang.model.type.UnknownTypeException;
+import javax.lang.model.util.ElementScanner7;
+import javax.lang.model.util.SimpleTypeVisitor7;
+import javax.lang.model.util.Types;
+
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.model.JavacTypes;
+import com.sun.tools.javac.util.Context;
+
+/**
+ * Scan javac Symtab looking for TypeMirrors and Elements, and ensure that
+ * no exceptions are thrown when used with javax.lang.model visitors.
+ *
+ */
+public class TestSymtabItems {
+    public static void main(String... args) throws Exception {
+        new TestSymtabItems().run();
+    }
+
+    void run() throws Exception {
+        Context c = new Context();
+        JavacFileManager.preRegister(c);
+        Symtab syms = Symtab.instance(c);
+        JavacTypes types = JavacTypes.instance(c);
+
+//        print("noSymbol", syms.noSymbol);
+//        print("errSymbol", syms.errSymbol);
+//        print("unknownSymbol", syms.unknownSymbol);
+//        print("botType", syms.botType);
+//        print("errType", syms.errType);
+//        print("unknownType", syms.unknownType);
+
+        for (Field f: Symtab.class.getDeclaredFields()) {
+//            System.err.println(f.getType() + " " + f.getName());
+
+            // Temporarily ignore methodHandle and transientMethodHandle
+            // during API evolution
+            if (f.getName().toLowerCase().contains("methodhandle"))
+                continue;
+
+            Class<?> ft = f.getType();
+            if (TypeMirror.class.isAssignableFrom(ft))
+                print(f.getName(), (TypeMirror) f.get(syms), types);
+            else if(Element.class.isAssignableFrom(ft))
+                print(f.getName(), (Element) f.get(syms));
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void print(String label, Element e) {
+        ElemPrinter ep = new ElemPrinter();
+        System.err.println("Test " + label);
+        ep.visit(e);
+        System.err.println();
+    }
+
+    void print(String label, TypeMirror t, Types types) {
+        TypePrinter tp = new TypePrinter();
+        System.err.println("Test " + label);
+        tp.visit(t, types);
+        System.err.println();
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+
+    class ElemPrinter extends ElementScanner7<Void, Void> {
+        @Override
+        public Void visitPackage(PackageElement e, Void p) {
+            show("package", e);
+            indent(+1);
+            super.visitPackage(e, p);
+            indent(-1);
+            return null;
+        }
+
+        @Override
+        public Void visitType(TypeElement e, Void p) {
+            show("type", e);
+            indent(+1);
+            super.visitType(e, p);
+            indent(-1);
+            return null;
+        }
+
+        @Override
+        public Void visitVariable(VariableElement e, Void p) {
+            show("variable", e);
+            indent(+1);
+            super.visitVariable(e, p);
+            indent(-1);
+            return null;
+        }
+
+        @Override
+        public Void visitExecutable(ExecutableElement e, Void p) {
+            show("executable", e);
+            indent(+1);
+            super.visitExecutable(e, p);
+            indent(-1);
+            return null;
+        }
+
+        @Override
+        public Void visitTypeParameter(TypeParameterElement e, Void p) {
+            show("type parameter", e);
+            indent(+1);
+            super.visitTypeParameter(e, p);
+            indent(-1);
+            return null;
+        }
+
+        @Override
+        public Void visitUnknown(Element e, Void p) {
+            show("unknown", e);
+            indent(+1);
+            try {
+                super.visitUnknown(e, p);
+            } catch (UnknownElementException ex) {
+                System.err.println("caught " + ex);
+            }
+            indent(-1);
+            return null;
+        }
+
+        void indent(int i) {
+            indent += i;
+        }
+
+        String sp(int w) {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < w; i++)
+                sb.append("    ");
+            return sb.toString();
+        }
+
+        void show(String label, Element e) {
+            System.err.println(sp(indent) + label
+                    + ": mods:" + e.getModifiers()
+                    + " " + e.getSimpleName()
+                    + ", kind: " + e.getKind()
+                    + ", type: " + e.asType()
+                    + ", encl: " + e.getEnclosingElement());
+
+            // The following checks help establish why NPE might occur when trying to scan children
+            if (e instanceof ClassSymbol) {
+                ClassSymbol csym = (ClassSymbol) e;
+                if (csym.members_field == null)
+                    error("members_field is null");
+                if (csym.type == null)
+                    System.err.println("type is null");
+            }
+        }
+
+        int indent;
+    };
+
+    class TypePrinter extends SimpleTypeVisitor7<Void, Types> {
+        @Override
+        public Void defaultAction(TypeMirror m, Types types) {
+            System.err.println(m.getKind() + " " + m + " " + types.asElement(m));
+            return null;
+        }
+
+        @Override
+        public Void visitUnknown(TypeMirror t, Types types) {
+            try {
+                return super.visitUnknown(t, types);
+            } catch (UnknownTypeException ex) {
+                System.err.println("caught " + ex);
+                return null;
+            }
+        }
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement/InvalidSource.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.util.*;
+
+@interface ExpectInterfaces {
+    String value();
+}
+
+@interface ExpectSupertype {
+    String value();
+}
+
+interface OK {
+    void m();
+}
+
+class InvalidSource {
+    /*
+     * The following annotations contain a simple description of the expected
+     * representation of the superclass and superinterfaces of the corresponding
+     * elements.
+     * The strings contain a comma-separated list of descriptions.
+     * Descriptions are composed as follows:
+     * A leading "!:" indicates the type mirror has kind ERROR.
+     * "empty" means that the corresponding element has no enclosed elements.
+     * "clss", "intf" and "tvar" indicate the name refers to a class, interface
+     * or type variable. Each is followed by the declared name of the element.
+     * "pkg" indicates the name of a package element.
+     * An enclosing element is shown in parentheses.
+     * A trailing "!" indicates that the element's type has kind ERROR.
+     */
+
+    @ExpectSupertype("!:empty clss A!")
+    class TestClassMissingClassA extends A { }
+
+    @ExpectSupertype("!:empty clss (pkg A).B!")
+    class TestClassMissingClassAB extends A.B { }
+
+    @ExpectSupertype("!:empty clss (pkg java.util).A!")
+    class TestClassMissingClass_juA extends java.util.A { }
+
+    @ExpectSupertype("!:empty clss A!<tvar T>")
+    class TestClassTMissingClassAT<T> extends A<T> { }
+
+    @ExpectInterfaces("!:empty intf A!")
+    class TestClassMissingIntfA implements A { }
+
+    @ExpectInterfaces("!:empty intf (pkg A).B!")
+    class TestClassMissingIntfAB implements A.B { }
+
+    @ExpectInterfaces("!:empty intf A!, intf OK")
+    abstract class TestClassMissingIntfAOK implements A, OK { }
+
+    @ExpectInterfaces("intf OK, !:empty intf A!")
+    abstract class TestClassOKMissingIntfA implements OK, A { }
+
+    @ExpectInterfaces("!:empty intf A!, !:empty intf B!")
+    class TestClassMissingIntfA_B implements A, B { }
+
+    @ExpectInterfaces("!:empty intf A!")
+    interface TestIntfMissingIntfA extends A { }
+
+    @ExpectInterfaces("!:empty intf A!, intf OK")
+    interface TestIntfMissingIntfAOK extends A, OK { }
+
+    @ExpectInterfaces("intf OK, !:empty intf A!")
+    interface TestIntfOKMissingIntfA extends OK, A { }
+
+    @ExpectInterfaces("!:empty intf A!, !:empty intf B!")
+    interface TestIntfMissingIntfAB extends A, B { }
+
+    @ExpectInterfaces("!:empty intf A!<tvar T>")
+    class TestClassTMissingIntfAT<T> implements A<T> { }
+
+    @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!")
+    class TestClassTMissingIntfAT_B<T> implements A<T>, B { }
+
+    @ExpectInterfaces("!:empty intf A!<tvar T>")
+    interface TestIntfTMissingIntfAT<T> extends A<T> { }
+
+    @ExpectInterfaces("!:empty intf A!<tvar T>, !:empty intf B!")
+    interface TestIntfTMissingIntfAT_B<T> extends A<T>, B { }
+
+    @ExpectInterfaces("intf (pkg java.util).List<!:empty clss X!>")
+    abstract class TestClassListMissingX implements List<X> { }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement/TestMissingElement.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ * @test
+ * @bug 6639645
+ * @summary Modeling type implementing missing interfaces
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor TestMissingElement
+ * @compile -proc:only -XprintRounds -processor TestMissingElement InvalidSource.java
+ */
+
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.type.*;
+import javax.lang.model.util.*;
+import static javax.tools.Diagnostic.Kind.*;
+
+public class TestMissingElement extends JavacTestingAbstractProcessor {
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        for (TypeElement te: ElementFilter.typesIn(roundEnv.getRootElements())) {
+            if (isSimpleName(te, "InvalidSource")) {
+                for (Element c: te.getEnclosedElements()) {
+                    for (AnnotationMirror am: c.getAnnotationMirrors()) {
+                        Element ate = am.getAnnotationType().asElement();
+                        if (isSimpleName(ate, "ExpectInterfaces")) {
+                            checkInterfaces((TypeElement) c, getValue(am));
+                        } else if (isSimpleName(ate, "ExpectSupertype")) {
+                            checkSupertype((TypeElement) c, getValue(am));
+                        }
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    private boolean isSimpleName(Element e, String name) {
+        return e.getSimpleName().contentEquals(name);
+    }
+
+    private String getValue(AnnotationMirror am) {
+        Map<? extends ExecutableElement, ? extends AnnotationValue> map = am.getElementValues();
+        if (map.size() != 1) throw new IllegalArgumentException();
+        AnnotationValue v = map.values().iterator().next();
+        return (String) v.getValue();
+    }
+
+    private void checkInterfaces(TypeElement te, String expect) {
+        System.err.println("check interfaces: " + te + " -- " + expect);
+        String found = asString(te.getInterfaces(), ", ");
+        checkEqual("interfaces", te, found, expect);
+    }
+
+    private void checkSupertype(TypeElement te, String expect) {
+        System.err.println("check supertype: " + te + " -- " + expect);
+        String found = asString(te.getSuperclass());
+        checkEqual("supertype", te, found, expect);
+    }
+
+    private void checkEqual(String label, TypeElement te, String found, String expect) {
+        if (found.equals(expect)) {
+//            messager.printMessage(NOTE, "expected " + label + " found: " + expect, te);
+        } else {
+            System.err.println("unexpected " + label + ": " + te + "\n"
+                    + " found: " + found + "\n"
+                    + "expect: " + expect);
+            messager.printMessage(ERROR, "unexpected " + label + " found: " + found + "; expected: " + expect, te);
+        }
+    }
+
+    private String asString(List<? extends TypeMirror> ts, String sep) {
+        StringBuilder sb = new StringBuilder();
+        for (TypeMirror t: ts) {
+            if (sb.length() != 0) sb.append(sep);
+            sb.append(asString(t));
+        }
+        return sb.toString();
+    }
+
+    private String asString(TypeMirror t) {
+        if (t == null)
+            return "[typ:null]";
+        return t.accept(new SimpleTypeVisitor7<String, Void>() {
+            @Override
+            public String defaultAction(TypeMirror t, Void ignore) {
+                return "[typ:" + t.toString() + "]";
+            }
+
+            @Override
+            public String visitDeclared(DeclaredType t, Void ignore) {
+                String s = asString(t.asElement());
+                List<? extends TypeMirror> args = t.getTypeArguments();
+                if (!args.isEmpty())
+                    s += "<" + asString(args, ",") + ">";
+                return s;
+            }
+
+            @Override
+            public String visitTypeVariable(TypeVariable t, Void ignore) {
+                return "tvar " + t;
+            }
+
+            @Override
+            public String visitError(ErrorType t, Void ignore) {
+                return "!:" + visitDeclared(t, ignore);
+            }
+        }, null);
+    }
+
+    private String asString(Element e) {
+        if (e == null)
+            return "[elt:null]";
+        return e.accept(new SimpleElementVisitor7<String, Void>() {
+            @Override
+            public String defaultAction(Element e, Void ignore) {
+                return "[elt:" + e.getKind() + " " + e.toString() + "]";
+            }
+            @Override
+            public String visitPackage(PackageElement e, Void ignore) {
+                return "pkg " + e.getQualifiedName();
+            }
+            @Override
+            public String visitType(TypeElement e, Void ignore) {
+                StringBuilder sb = new StringBuilder();
+                if (e.getEnclosedElements().isEmpty())
+                    sb.append("empty ");
+                ElementKind ek = e.getKind();
+                switch (ek) {
+                    case CLASS:
+                        sb.append("clss");
+                        break;
+                    case INTERFACE:
+                        sb.append("intf");
+                        break;
+                    default:
+                        sb.append(ek);
+                        break;
+                }
+                sb.append(" ");
+                Element encl = e.getEnclosingElement();
+                if (!isUnnamedPackage(encl) && encl.asType().getKind() != TypeKind.NONE) {
+                    sb.append("(");
+                    sb.append(asString(encl));
+                    sb.append(")");
+                    sb.append(".");
+                }
+                sb.append(e.getSimpleName());
+                if (e.asType().getKind() == TypeKind.ERROR) sb.append("!");
+                return sb.toString();
+            }
+        }, null);
+    }
+
+    boolean isUnnamedPackage(Element e) {
+        return (e != null && e.getKind() == ElementKind.PACKAGE
+                && ((PackageElement) e).isUnnamed());
+    }
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement2/Generator.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.lang.model.type.*;
+import javax.lang.model.util.*;
+import javax.tools.*;
+
+public class Generator extends JavacTestingAbstractProcessor {
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        for (TypeElement te: ElementFilter.typesIn(roundEnv.getRootElements())) {
+            System.err.println(te);
+            generateIfMissing(te.getSuperclass());
+            generateIfMissing(te.getInterfaces());
+        }
+        return true;
+    }
+
+    void generateIfMissing(List<? extends TypeMirror> ts) {
+        for (TypeMirror t: ts)
+            generateIfMissing(t);
+    }
+
+    void generateIfMissing(TypeMirror t) {
+        if (t == null)
+            return;
+        if (t.getKind() == TypeKind.ERROR) {
+            Element e = ((ErrorType) t).asElement();
+            if (e == null)
+                return;
+            if (e.asType().getKind() == TypeKind.ERROR)
+                createFile((TypeElement) e);
+        }
+    }
+
+    void createFile(TypeElement e) {
+        try {
+            JavaFileObject fo = filer.createSourceFile(e.getSimpleName());
+            Writer out = fo.openWriter();
+            try {
+                switch (e.getKind()) {
+                    case CLASS:
+                        out.write("import java.util.*;\n");
+                        out.write("class " + signature(e) + " {\n");
+                        out.write("    public void run() {\n");
+                        out.write("        Class<?> c = getClass();\n");
+                        out.write("        System.out.println(\"class: \" + c);\n");
+                        out.write("        System.out.println(\"superclass: \" + c.getSuperclass());\n");
+                        out.write("        System.out.println(\"generic superclass: \" +c.getGenericSuperclass());\n");
+                        out.write("        System.out.println(\"interfaces: \" + Arrays.asList(c.getInterfaces()));\n");
+                        out.write("        System.out.println(\"generic interfaces: \" + Arrays.asList(c.getGenericInterfaces()));\n");
+                        out.write("    }\n");
+                        out.write("}\n");
+                        break;
+                    case INTERFACE:
+                        out.write("interface " + signature(e) + " {\n");
+                        out.write("    void run();\n");
+                        out.write("}\n");
+                        break;
+                }
+            } finally {
+                out.close();
+            }
+        } catch (IOException ex) {
+            messager.printMessage(Diagnostic.Kind.ERROR, "problem writing file: " + ex);
+        }
+    }
+
+    String signature(TypeElement e) {
+        System.err.println("signature: " + e + " " + e.getTypeParameters());
+        StringBuilder sb = new StringBuilder();
+        sb.append(e.getSimpleName());
+        if (!e.getTypeParameters().isEmpty()) {
+            sb.append("<");
+            String sep = "";
+            for (TypeParameterElement t : e.getTypeParameters()) {
+                sb.append(sep);
+                sb.append(t);
+                sep = ",";
+            }
+            sb.append(">");
+        }
+        return sb.toString();
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingClass.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6639645
+ * @summary Modeling type implementing missing interfaces
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor Generator
+ * @compile -XprintRounds -processor Generator TestMissingClass.java
+ * @run main TestMissingClass
+ */
+
+public class TestMissingClass extends MissingClass {
+    public static void main(String... args) {
+        new TestMissingClass().run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass1.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6639645
+ * @summary Modeling type implementing missing interfaces
+ * @library ../../../../lib
+ * @clean MissingGenericClass1
+ * @build JavacTestingAbstractProcessor Generator
+ * @compile -XprintRounds -processor Generator TestMissingGenericClass1.java
+ * @run main TestMissingGenericClass1
+ */
+
+public class TestMissingGenericClass1 extends MissingGenericClass1<String> {
+    public static void main(String... args) {
+        new TestMissingGenericClass1().run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericClass2.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6639645
+ * @summary Modeling type implementing missing interfaces
+ * @library ../../../../lib
+ * @clean MissingGenericClass2
+ * @build JavacTestingAbstractProcessor Generator
+ * @compile -XprintRounds -processor Generator TestMissingGenericClass2.java
+ * @run main TestMissingGenericClass2
+ */
+
+public class TestMissingGenericClass2 extends MissingGenericClass2<String,Integer> {
+    public static void main(String... args) {
+        new TestMissingGenericClass2().run();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface1.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, asrm
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6639645
+ * @summary Modeling type implementing missing interfaces
+ * @library ../../../../lib
+ * @clean MissingGenericInterface1
+ * @build JavacTestingAbstractProcessor Generator
+ * @compile -XprintRounds -processor Generator TestMissingGenericInterface1.java
+ * @run main TestMissingGenericInterface1
+ */
+
+import java.util.*;
+
+public class TestMissingGenericInterface1 implements MissingGenericInterface1<String> {
+    public static void main(String... args) {
+        new TestMissingGenericInterface1().run();
+    }
+
+    @Override
+    public void run() {
+        Class<?> c = getClass();
+        System.out.println("class: " + c);
+        System.out.println("superclass: " + c.getSuperclass());
+        System.out.println("generic superclass: " +c.getGenericSuperclass());
+        System.out.println("interfaces: " + Arrays.asList(c.getInterfaces()));
+        System.out.println("generic interfaces: " + Arrays.asList(c.getGenericInterfaces()));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingGenericInterface2.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, asrm
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6639645
+ * @summary Modeling type implementing missing interfaces
+ * @library ../../../../lib
+ * @clean MissingGenericInterface2
+ * @build JavacTestingAbstractProcessor Generator
+ * @compile -XprintRounds -processor Generator TestMissingGenericInterface2.java
+ * @run main TestMissingGenericInterface2
+ */
+
+import java.util.*;
+
+public class TestMissingGenericInterface2 implements MissingGenericInterface2<Integer,String> {
+    public static void main(String... args) {
+        new TestMissingGenericInterface2().run();
+    }
+
+    @Override
+    public void run() {
+        Class<?> c = getClass();
+        System.out.println("class: " + c);
+        System.out.println("superclass: " + c.getSuperclass());
+        System.out.println("generic superclass: " +c.getGenericSuperclass());
+        System.out.println("interfaces: " + Arrays.asList(c.getInterfaces()));
+        System.out.println("generic interfaces: " + Arrays.asList(c.getGenericInterfaces()));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/model/element/TestMissingElement2/TestMissingInterface.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, asrm
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6639645
+ * @summary Modeling type implementing missing interfaces
+ * @library ../../../../lib
+ * @build JavacTestingAbstractProcessor Generator
+ * @compile -XprintRounds -processor Generator TestMissingInterface.java
+ * @run main TestMissingInterface
+ */
+
+import java.util.*;
+
+public class TestMissingInterface implements MissingInterface {
+    public static void main(String... args) {
+        new TestMissingInterface().run();
+    }
+
+    @Override
+    public void run() {
+        Class<?> c = getClass();
+        System.out.println("class: " + c);
+        System.out.println("superclass: " + c.getSuperclass());
+        System.out.println("generic superclass: " +c.getGenericSuperclass());
+        System.out.println("interfaces: " + Arrays.asList(c.getInterfaces()));
+        System.out.println("generic interfaces: " + Arrays.asList(c.getGenericInterfaces()));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/warnings/UseImplicit/C1.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+class C1 extends p.C2 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/warnings/UseImplicit/TestProcUseImplicitWarning.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6986892
+ * @summary confusing warning given after errors in annotation processing
+ * @library ../../../lib
+ * @build JavacTestingAbstractProcessor TestProcUseImplicitWarning
+ * @clean C1 p.C2
+ * @compile/fail/ref=err.out -XDrawDiagnostics -processor TestProcUseImplicitWarning -Aerror C1.java
+ * @clean C1 p.C2
+ * @compile/ref=warn.out     -XDrawDiagnostics -processor TestProcUseImplicitWarning         C1.java
+ */
+
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import static javax.tools.Diagnostic.Kind.*;
+
+@SupportedOptions("error")
+public class TestProcUseImplicitWarning extends JavacTestingAbstractProcessor {
+
+    int round = 0;
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+
+        if (round == 1) {
+            boolean error = options.containsKey("error");
+            if (error)
+                messager.printMessage(ERROR, "error generated per option");
+        }
+
+        return false;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/warnings/UseImplicit/err.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,2 @@
+- compiler.err.proc.messager: error generated per option
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/warnings/UseImplicit/p/C2.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package p;
+
+public class C2 { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/processing/warnings/UseImplicit/warn.out	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,2 @@
+- compiler.warn.proc.use.implicit
+1 warning
--- a/langtools/test/tools/javac/processing/warnings/gold_0.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/processing/warnings/gold_0.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,1 +1,2 @@
 - compiler.warn.proc.messager: No SourceVersion option given
+1 warning
--- a/langtools/test/tools/javac/processing/warnings/gold_sv_warn_0_2.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/processing/warnings/gold_sv_warn_0_2.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,1 +1,2 @@
 - compiler.warn.proc.processor.incompatible.source.version: RELEASE_0, TestSourceVersionWarnings, 1.2
+1 warning
--- a/langtools/test/tools/javac/processing/warnings/gold_sv_warn_2_3.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/processing/warnings/gold_sv_warn_2_3.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,1 +1,2 @@
 - compiler.warn.proc.processor.incompatible.source.version: RELEASE_2, TestSourceVersionWarnings, 1.3
+1 warning
--- a/langtools/test/tools/javac/processing/warnings/gold_sv_warn_5_6.out	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/processing/warnings/gold_sv_warn_5_6.out	Thu Mar 10 20:51:07 2011 -0800
@@ -1,1 +1,2 @@
 - compiler.warn.proc.processor.incompatible.source.version: RELEASE_5, TestSourceVersionWarnings, 1.6
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/util/context/T7021650.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7021650
+ * @summary Fix Context issues
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor T7021650
+ * @run main T7021650
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.annotation.processing.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.Main;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+
+public class T7021650 extends JavacTestingAbstractProcessor {
+    public static void main(String... args) throws Exception {
+        new T7021650().run();
+    }
+
+    static File testSrc = new File(System.getProperty("test.src"));
+    static final int MAX_ROUNDS = 3;
+
+    /**
+     * Perform a compilation with custom factories registered in the context,
+     * and verify that corresponding objects are created in each round.
+     */
+    void run() throws Exception {
+        Counter demoCounter = new Counter();
+        Counter myAttrCounter = new Counter();
+
+        Context context = new Context();
+        // Use a custom file manager which creates classloaders for annotation
+        // processors with a sensible delegation parent, so that all instances
+        // of test classes come from the same class loader. This is important
+        // because the test performs class checks on the instances of classes
+        // found in the context for each round or processing.
+        context.put(JavaFileManager.class, new Context.Factory<JavaFileManager>() {
+            public JavaFileManager make(Context c) {
+                return new JavacFileManager(c, true, null) {
+                    @Override
+                    protected ClassLoader getClassLoader(URL[] urls) {
+                        return new URLClassLoader(urls, T7021650.class.getClassLoader());
+                    }
+                };
+            }
+        });
+
+        Demo.preRegister(context, demoCounter);
+        MyAttr.preRegister(context, myAttrCounter);
+
+        String[] args = {
+            "-d", ".",
+            "-processor", T7021650.class.getName(),
+            "-XprintRounds",
+            new File(testSrc, T7021650.class.getName() + ".java").getPath()
+        };
+
+        compile(context, args);
+
+        // Expect to create Demo for initial round, then MAX_ROUNDS in which
+        // GenX files are generated, then standard final round of processing.
+        checkEqual("demoCounter", demoCounter.count, MAX_ROUNDS + 2);
+
+        // Expect to create MyAttr for same processing rounds as for Demo,
+        // plus additional context for final compilation.
+        checkEqual("myAttrCounter", myAttrCounter.count, MAX_ROUNDS + 3);
+    }
+
+    void compile(Context context, String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        Main m = new Main("javac", pw);
+        int rc = m.compile(args, context);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("compilation failed unexpectedly: rc=" + rc);
+    }
+
+    void checkEqual(String label, int found, int expect) throws Exception {
+        if (found != expect)
+            throw new Exception("unexpected value for " + label
+                    + ": expected " + expect
+                    + ": found " + found);
+    }
+
+    //---------------
+
+    /*
+     * A custom class unknown to javac but nonetheless registered in the context.
+     */
+    static class Demo {
+        static void preRegister(Context context, final Counter counter) {
+            context.put(Demo.class, new Context.Factory<Demo>() {
+                public Demo make(Context c) {
+                    counter.count++;
+                    return new Demo(c);
+                }
+            });
+        }
+
+        Demo(Context c) {
+            c.put(Demo.class, this);
+        }
+
+        static Demo instance(Context context) {
+            return context.get(Demo.class);
+        }
+    }
+
+    /**
+     * A custom version of a standard javac component.
+     */
+    static class MyAttr extends Attr {
+        static void preRegister(Context context, final Counter counter) {
+            context.put(attrKey, new Context.Factory<Attr>() {
+                public Attr make(Context c) {
+                    counter.count++;
+                    return new MyAttr(c);
+                }
+            });
+        }
+
+        MyAttr(Context c) {
+            super(c);
+        }
+    }
+
+    static class Counter {
+        int count;
+    }
+
+    //---------------
+
+    int round = 0;
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        round++;
+
+        Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
+
+        // verify items in context as expected
+        check("Demo", Demo.instance(context), Demo.class);
+        check("Attr", Attr.instance(context), MyAttr.class);
+
+        // For a few rounds, generate new source files, so that we can check whether
+        // values in the context are correctly handled in subsequent processing rounds
+        if (round <= MAX_ROUNDS) {
+            String pkg = "p";
+            String currClass = "Gen" + round;
+            String curr = pkg + "." + currClass;
+            String next = (pkg + ".Gen" + (round + 1));
+            StringBuilder text = new StringBuilder();
+            text.append("package ").append(pkg).append(";\n");
+            text.append("public class ").append(currClass).append(" {\n");
+            if (round < MAX_ROUNDS)
+                text.append("    ").append(next).append(" x;\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;
+    }
+
+    void check(String label, Object o, Class<?> clazz) {
+        if (o == null)
+            throw new IllegalStateException(label + ": no item found");
+        if (!clazz.isAssignableFrom(o.getClass()))
+            throw new IllegalStateException(label + ": unexpected class: " + o.getClass());
+    }
+}
--- a/langtools/test/tools/javac/varargs/6199075/T6199075.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/varargs/6199075/T6199075.java	Thu Mar 10 20:51:07 2011 -0800
@@ -37,6 +37,7 @@
 import com.sun.tools.classfile.Code_attribute;
 import com.sun.tools.classfile.ConstantPool.*;
 import com.sun.tools.classfile.Method;
+import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.util.List;
 
 import java.io.File;
@@ -47,6 +48,7 @@
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
 
 public class T6199075 {
@@ -157,11 +159,14 @@
         System.out.println("Bytecode checks made: " + bytecodeCheckCount);
     }
 
+    // Create a single file manager and reuse it for each compile to save time.
+    StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+
     void compileAndCheck(VarargsMethod m1, VarargsMethod m2, TypeKind actual, ArgumentsArity argsArity) throws Exception {
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         JavaSource source = new JavaSource(m1, m2, actual, argsArity);
         ErrorChecker ec = new ErrorChecker();
-        JavacTask ct = (JavacTask)tool.getTask(null, null, ec,
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, ec,
                 null, null, Arrays.asList(source));
         ct.generate();
         check(source, ec, m1, m2, actual, argsArity);
--- a/langtools/test/tools/javac/varargs/warning/Warn4.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/varargs/warning/Warn4.java	Thu Mar 10 20:51:07 2011 -0800
@@ -29,6 +29,7 @@
  * @run main Warn4
  */
 import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Set;
@@ -37,6 +38,7 @@
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
 
 public class Warn4 {
@@ -187,12 +189,15 @@
         }
     }
 
+    // Create a single file manager and reuse it for each compile to save time.
+    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+
     static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient,
             SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
         DiagnosticChecker dc = new DiagnosticChecker();
-        JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
                 Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey),
                 null, Arrays.asList(source));
         ct.generate(); //to get mandatory notes
--- a/langtools/test/tools/javac/varargs/warning/Warn5.java	Thu Mar 10 17:11:19 2011 -0800
+++ b/langtools/test/tools/javac/varargs/warning/Warn5.java	Thu Mar 10 20:51:07 2011 -0800
@@ -29,6 +29,7 @@
  * @run main Warn5
  */
 import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTool;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -36,6 +37,7 @@
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
 import javax.tools.ToolProvider;
 
 public class Warn5 {
@@ -207,12 +209,15 @@
         }
     }
 
+    // Create a single file manager and reuse it for each compile to save time.
+    static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
+
     static void test(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel,
             ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) throws Exception {
         final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
         JavaSource source = new JavaSource(trustMe, suppressLevel, modKind, methKind, sig, body);
         DiagnosticChecker dc = new DiagnosticChecker();
-        JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
                 Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
         ct.analyze();
         check(sourceLevel, dc, source, xlint, trustMe,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/6227454/Test.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6227454
+ * @summary package.html and overview.html may not be read fully
+ */
+
+import java.io.*;
+
+import com.sun.javadoc.Doclet;
+import com.sun.javadoc.RootDoc;
+
+public class Test extends Doclet {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    void run() throws Exception {
+        test("<html><body>ABC      XYZ</body></html>");
+        test("<html><body>ABC      XYZ</BODY></html>");
+        test("<html><BODY>ABC      XYZ</body></html>");
+        test("<html><BODY>ABC      XYZ</BODY></html>");
+        test("<html><BoDy>ABC      XYZ</bOdY></html>");
+        test("<html>      ABC      XYZ</bOdY></html>", "Body tag missing from HTML");
+        test("<html><body>ABC      XYZ       </html>", "Close body tag missing from HTML");
+        test("<html>      ABC      XYZ       </html>", "Body tag missing from HTML");
+        test("<html><body>ABC" + bigText(8192, 40) + "XYZ</body></html>");
+
+        if (errors > 0)
+            throw new Exception(errors + " errors occurred");
+    }
+
+    void test(String text) throws IOException {
+        test(text, null);
+    }
+
+    void test(String text, String expectError) throws IOException {
+        testNum++;
+        System.err.println("test " + testNum);
+        File file = writeFile("overview" + testNum + ".html", text);
+        String thisClassName = Test.class.getName();
+        File testSrc = new File(System.getProperty("test.src"));
+        String[] args = {
+            "-bootclasspath",
+                System.getProperty("java.class.path")
+                + File.pathSeparator
+                + System.getProperty("sun.boot.class.path"),
+            "-classpath", ".",
+            "-package",
+            "-overview", file.getPath(),
+            new File(testSrc, thisClassName + ".java").getPath()
+        };
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javadoc.Main.execute(
+                "javadoc",
+                pw, pw, pw,
+                thisClassName,
+                args);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        System.err.println("javadoc exit: rc=" + rc);
+
+        if (expectError == null) {
+            if (rc != 0)
+                error("unexpected exit from javadoc; rc:" + rc);
+        } else {
+            if (!out.contains(expectError))
+                error("expected error text not found: " + expectError);
+        }
+    }
+
+    String bigText(int lines, int lineLength) {
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < lineLength; i++)
+            sb.append(String.valueOf(i % 10));
+        sb.append("\n");
+        String line = sb.toString();
+        sb.setLength(0);
+        for (int i = 0; i < lines; i++)
+            sb.append(line);
+        return sb.toString();
+    }
+
+    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;
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int testNum;
+    int errors;
+
+    public static boolean start(RootDoc root) {
+        String text = root.commentText();
+        if (text.length() < 64)
+            System.err.println("text: '" + text + "'");
+        else
+            System.err.println("text: '"
+                    + text.substring(0, 20)
+                    + "..."
+                    + text.substring(text.length() - 20)
+                    + "'");
+        return text.startsWith("ABC") && text.endsWith("XYZ");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/6964914/Error.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 Error {
+    Object x // no semicolon
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/6964914/JavacWarning.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 JavacWarning {
+    int enum;  // warning in source 1.4
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/6964914/JavadocWarning.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please 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 JavadocWarning {
+    /** @see DoesNotExist */
+    int x;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/6964914/Test.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6964914
+ * @summary javadoc does not output number of warnings using user written doclet
+ */
+
+import java.io.*;
+
+public class Test {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    public void run() throws Exception {
+        javadoc("Error.java", "1 error");
+        javadoc("JavacWarning.java", "1 warning");
+        javadoc("JavadocWarning.java", "1 warning");
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void javadoc(String path, String expect) {
+        File testSrc = new File(System.getProperty("test.src"));
+        String[] args = {
+            "-source", "1.4", // enables certain Parser warnings
+            "-bootclasspath", System.getProperty("sun.boot.class.path"),
+            "-classpath", ".",
+            "-package",
+            new File(testSrc, path).getPath()
+        };
+
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javadoc.Main.execute(
+                "javadoc",
+                pw, pw, pw,
+                com.sun.tools.doclets.standard.Standard.class.getName(),
+                args);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        System.err.println("javadoc exit: rc=" + rc);
+
+        if (!out.contains(expect))
+            error("expected text not found: " + expect);
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/6964914/TestStdDoclet.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6964914
+ * @summary javadoc does not output number of warnings using user written doclet
+ */
+
+import java.io.*;
+
+/**
+ * Dummy javadoc comment.
+ * @author jjg
+ * @see DoesNotExist
+ */
+public class TestStdDoclet {
+    public static void main(String... args) throws Exception {
+        new TestStdDoclet().run();
+    }
+
+    /**
+     * More dummy comments.
+     * @throws DoesNotExist   oops, javadoc does not see this
+     * @see DoesNotExist
+     */
+    void run() throws Exception {
+        File javaHome = new File(System.getProperty("java.home"));
+        if (javaHome.getName().equals("jre"))
+            javaHome = javaHome.getParentFile();
+        File javadoc = new File(new File(javaHome, "bin"), "javadoc");
+        File testSrc = new File(System.getProperty("test.src"));
+
+        // run javadoc in separate process to ensure doclet executed under
+        // normal user conditions w.r.t. classloader
+        String thisClassName = TestStdDoclet.class.getName();
+        Process p = new ProcessBuilder()
+            .command(javadoc.getPath(),
+                "-J-Xbootclasspath:" + System.getProperty("sun.boot.class.path"),
+                "-package",
+                new File(testSrc, thisClassName + ".java").getPath())
+            .redirectErrorStream(true)
+            .start();
+
+        int actualDocletWarnCount = 0;
+        int reportedDocletWarnCount = 0;
+        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+        try {
+            String line;
+            while ((line = in.readLine()) != null) {
+                System.err.println(line);
+                if (line.contains("DoesNotExist"))
+                    actualDocletWarnCount++;
+                if (line.matches("[0-9]+ warning(s)?"))
+                    reportedDocletWarnCount =
+                            Integer.valueOf(line.substring(0, line.indexOf(" ")));
+            }
+        } finally {
+            in.close();
+        }
+        int rc = p.waitFor();
+        if (rc != 0)
+            System.err.println("javadoc failed, rc:" + rc);
+
+        int expectedDocletWarnCount = 2;
+        checkEqual("actual", actualDocletWarnCount, "expected", expectedDocletWarnCount);
+        checkEqual("actual", actualDocletWarnCount, "reported", reportedDocletWarnCount);
+    }
+
+    /**
+     * Private method should not cause a warning.
+     * @see DoesNotExist
+     */
+    private void checkEqual(String l1, int i1, String l2, int i2) throws Exception {
+        if (i1 != i2)
+            throw new Exception(l1 + " warn count, " + i1 + ", does not match "
+                        + l2 + " warn count, " + i2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/6964914/TestUserDoclet.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6964914
+ * @summary javadoc does not output number of warnings using user written doclet
+ */
+
+import java.io.*;
+import com.sun.javadoc.Doclet;
+import com.sun.javadoc.RootDoc;
+
+public class TestUserDoclet extends Doclet {
+    public static void main(String... args) throws Exception {
+        new TestUserDoclet().run();
+    }
+
+    static final String docletWarning = "warning from test doclet";
+
+    /** Main doclet method. */
+    public static boolean start(RootDoc root) {
+        root.printWarning(null, docletWarning);
+        return true;
+    }
+
+    /** Main test method. */
+    void run() throws Exception {
+        File javaHome = new File(System.getProperty("java.home"));
+        if (javaHome.getName().equals("jre"))
+            javaHome = javaHome.getParentFile();
+        File javadoc = new File(new File(javaHome, "bin"), "javadoc");
+        File testSrc = new File(System.getProperty("test.src"));
+        File testClasses = new File(System.getProperty("test.classes"));
+
+        // run javadoc in separate process to ensure doclet executed under
+        // normal user conditions w.r.t. classloader
+        String thisClassName = TestUserDoclet.class.getName();
+        Process p = new ProcessBuilder()
+            .command(javadoc.getPath(),
+                "-J-Xbootclasspath:" + System.getProperty("sun.boot.class.path"),
+                "-doclet", thisClassName,
+                "-docletpath", testClasses.getPath(),
+                new File(testSrc, thisClassName + ".java").getPath())
+            .redirectErrorStream(true)
+            .start();
+
+        int actualDocletWarnCount = 0;
+        int reportedDocletWarnCount = 0;
+        BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
+        try {
+            String line;
+            while ((line = in.readLine()) != null) {
+                System.err.println(line);
+                if (line.contains(docletWarning))
+                    actualDocletWarnCount++;
+                if (line.matches("[0-9]+ warning(s)?"))
+                    reportedDocletWarnCount =
+                            Integer.valueOf(line.substring(0, line.indexOf(" ")));
+            }
+        } finally {
+            in.close();
+        }
+        int rc = p.waitFor();
+        if (rc != 0)
+            System.err.println("javadoc failed, rc:" + rc);
+
+        int expectedDocletWarnCount = 1;
+        checkEqual("actual", actualDocletWarnCount, "expected", expectedDocletWarnCount);
+        checkEqual("actual", actualDocletWarnCount, "reported", reportedDocletWarnCount);
+    }
+
+    void checkEqual(String l1, int i1, String l2, int i2) throws Exception {
+        if (i1 != i2)
+            throw new Exception(l1 + " warn count, " + i1 + ", does not match "
+                        + l2 + " warn count, " + i2);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javadoc/T6968833.java	Thu Mar 10 20:51:07 2011 -0800
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6968833
+ * @summary javadoc reports error but still returns 0
+ */
+
+import java.io.*;
+
+public class T6968833 {
+    public static void main(String... args) throws IOException {
+        new T6968833().run();
+    }
+
+    void run() throws IOException {
+        File srcDir = new File("src");
+        // following file causes error: No public or protected classes found to document.
+        File f = writeFile(srcDir, "Foo.java", "class Foo { }");
+        String[] args = { f.getPath() };
+        int rc = com.sun.tools.javadoc.Main.execute(args);
+        if (rc == 0)
+            throw new Error("Unexpected exit from javadoc: " + rc);
+    }
+
+    File writeFile(File dir, String path, String s) throws IOException {
+        File f = new File(dir, path);
+        f.getParentFile().mkdirs();
+        try (Writer out = new FileWriter(f)) {
+            out.write(s);
+        }
+        return f;
+    }
+}
+