changeset 967:8e26c4aee63c icedtea-1.14

Merge
author andrew
date Wed, 20 Apr 2011 04:37:56 +0100
parents 4659da7bff78 a15c9b058ae0
children e128b170361a
files .hgtags make/build.xml src/share/classes/com/sun/tools/javac/jvm/ClassReader.java test/tools/javac/T6900037.java test/tools/javac/T6900037.out test/tools/javac/diags/examples/DiamondInvalidArg.java test/tools/javac/diags/examples/DiamondInvalidArgs.java test/tools/javac/multicatch/Neg05.java test/tools/javac/multicatch/Neg05.out
diffstat 246 files changed, 7933 insertions(+), 1624 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sat Apr 09 00:45:10 2011 +0100
+++ b/.hgtags	Wed Apr 20 04:37:56 2011 +0100
@@ -106,3 +106,10 @@
 1e6094c33187f6c3dca55ced3701ee1f9d73a77d jdk7-b127
 d7225b476a5d1aebffb8827e7c72ba2e1651f4e7 jdk7-b128
 1383d1ee8b5db13d5df9523d1760df17b9d228d4 jdk7-b129
+7a98db8cbfce77a619057aa4fdde69d2a06d4101 jdk7-b130
+67221b8643b478c4fceacc89240db876455aae76 jdk7-b131
+e3d011d59a33acef79eff7523bef069557e91002 jdk7-b132
+e77e98f936e83d94c9b56cc7af218dc822a06122 jdk7-b133
+3d7acdbb72cab55deedfd35f60d4732abc9d6ac4 jdk7-b134
+9d0a61ac567b983da7cc8f4a7030f2245bb6dbab jdk7-b135
+ed0f7f1f9511db4f9615b1426d22f8b961629275 jdk7-b136
--- a/LICENSE	Sat Apr 09 00:45:10 2011 +0100
+++ b/LICENSE	Wed Apr 20 04:37:56 2011 +0100
@@ -325,11 +325,11 @@
 
 "CLASSPATH" EXCEPTION TO THE GPL
 
-Certain source files distributed by Sun Microsystems, Inc.  are subject to
-the following clarification and special exception to the GPL, but only where
-Sun has expressly included in the particular source file's header the words
-"Sun designates this particular file as subject to the "Classpath" exception
-as provided by Sun in the LICENSE file that accompanied this code."
+Certain source files distributed by Oracle America and/or its affiliates are
+subject to the following clarification and special exception to the GPL, but
+only where Oracle has expressly included in the particular source file's header
+the words "Oracle designates this particular file as subject to the "Classpath"
+exception as provided by Oracle in the LICENSE file that accompanied this code."
 
     Linking this library statically or dynamically with other modules is making
     a combined work based on this library.  Thus, the terms and conditions of
--- a/make/build.xml	Sat Apr 09 00:45:10 2011 +0100
+++ b/make/build.xml	Wed Apr 20 04:37:56 2011 +0100
@@ -868,8 +868,10 @@
                executable="${boot.java.home}/bin/javac"
                srcdir="${make.tools.dir}/GenStubs"
                destdir="${build.toolclasses.dir}/"
-               classpath="${build.bootstrap.dir}/classes:${ant.core.lib}"
-               includeantruntime="false"/>
+               classpath="${ant.core.lib}"
+               includeantruntime="false">
+            <compilerarg value="-Xbootclasspath/p:${build.bootstrap.dir}/classes"/>
+        </javac>
         <taskdef name="genstubs"
                  classname="GenStubs$$Ant"
                  classpath="${build.toolclasses.dir}:${build.bootstrap.dir}/classes:${ant.home}/lib/ant.jar"/>
--- a/src/share/bin/launcher.sh-template	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/bin/launcher.sh-template	Wed Apr 20 04:37:56 2011 +0100
@@ -31,8 +31,7 @@
       mydir=`cygpath -m $mydir`
       ;;
 esac
-
-mylib="`dirname $mydir`"/lib
+mylib="$mydir/../lib"
 
 # By default, put the jar file and its dependencies on the bootclasspath.
 # This is always required on a Mac, because the system langtools classes
@@ -73,4 +72,4 @@
 unset DUALCASE
 
 IFS=$nl
-"#TARGET_JAVA#" "${bcp:+-Xbootclasspath/p:"$bcp"}" ${ea} ${javaOpts} -jar "${mydir}"/../lib/#PROGRAM#.jar ${toolOpts}
+"#TARGET_JAVA#" "${bcp:+-Xbootclasspath/p:"$bcp"}" ${ea} ${javaOpts} -jar "${mylib}/#PROGRAM#.jar" ${toolOpts}
--- a/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/apt/main/AptJavaCompiler.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/apt/util/Bark.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/apt/util/Bark.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/ClassUseWriter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -305,11 +305,7 @@
             tr.addContent(tdFirst);
             HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
             tdLast.addStyle(HtmlStyle.colLast);
-            if (pkg != null) {
-                addSummaryComment(pkg, tdLast);
-            } else {
-                tdLast.addContent(getSpace());
-            }
+            addSummaryComment(pkg, tdLast);
             tr.addContent(tdLast);
             tbody.addContent(tr);
         }
@@ -355,10 +351,7 @@
         contentTree.addContent(tdFirst);
         HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
         tdLast.addStyle(HtmlStyle.colLast);
-        if (pkg != null)
-            addSummaryComment(pkg, tdLast);
-        else
-            tdLast.addContent(getSpace());
+        addSummaryComment(pkg, tdLast);
         contentTree.addContent(tdLast);
     }
 
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -283,23 +283,32 @@
         Content framePara = HtmlTree.P(line26);
         liFrame.addContent(framePara);
         ul.addContent(liFrame);
+        Content allclassesHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
+                getResource("doclet.All_Classes"));
+        Content liAllClasses = HtmlTree.LI(HtmlStyle.blockList, allclassesHead);
+        Content line27 = getResource("doclet.Help_line_27",
+                getHyperLinkString("allclasses-noframe.html",
+                configuration.getText("doclet.All_Classes")));
+        Content allclassesPara = HtmlTree.P(line27);
+        liAllClasses.addContent(allclassesPara);
+        ul.addContent(liAllClasses);
         Content sHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
                 getResource("doclet.Serialized_Form"));
         Content liSerial = HtmlTree.LI(HtmlStyle.blockList, sHead);
-        Content line27 = getResource("doclet.Help_line_27");
-        Content serialPara = HtmlTree.P(line27);
+        Content line28 = getResource("doclet.Help_line_28");
+        Content serialPara = HtmlTree.P(line28);
         liSerial.addContent(serialPara);
         ul.addContent(liSerial);
         Content constHead = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING,
                 getResource("doclet.Constants_Summary"));
         Content liConst = HtmlTree.LI(HtmlStyle.blockList, constHead);
-        Content line28 = getResource("doclet.Help_line_28");
-        Content constPara = HtmlTree.P(line28);
+        Content line29 = getResource("doclet.Help_line_29");
+        Content constPara = HtmlTree.P(line29);
         liConst.addContent(constPara);
         ul.addContent(liConst);
         Content divContent = HtmlTree.DIV(HtmlStyle.contentContainer, ul);
-        Content line29 = HtmlTree.EM(getResource("doclet.Help_line_29"));
-        divContent.addContent(line29);
+        Content line30 = HtmlTree.EM(getResource("doclet.Help_line_30"));
+        divContent.addContent(line30);
         contentTree.addContent(divContent);
     }
 
--- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlSerialFieldWriter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/PackageUseWriter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -246,10 +246,7 @@
         contentTree.addContent(tdFirst);
         HtmlTree tdLast = new HtmlTree(HtmlTag.TD);
         tdLast.addStyle(HtmlStyle.colLast);
-        if (pkg != null)
-            addSummaryComment(pkg, tdLast);
-        else
-            tdLast.addContent(getSpace());
+        addSummaryComment(pkg, tdLast);
         contentTree.addContent(tdLast);
     }
 
--- a/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/SourceToHTMLConverter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/formats/html/resources/standard.properties	Wed Apr 20 04:37:56 2011 +0100
@@ -11,15 +11,25 @@
 doclet.Interface_Hierarchy=Interface Hierarchy
 doclet.Enum_Hierarchy=Enum Hierarchy
 doclet.Annotation_Type_Hierarchy=Annotation Type Hierarchy
+# The following ALL CAPS words should be translated. It is used as "Previous" link on javadoc.
 doclet.Prev=PREV
+# The following ALL CAPS words should be translated. It is used as "Next" link on javadoc.
 doclet.Next=NEXT
+# The following ALL CAPS words should be translated. It is used as "Previous Class" link on javadoc.
 doclet.Prev_Class=PREV CLASS
+# The following ALL CAPS words should be translated. It is used as "Next Class" link on javadoc.
 doclet.Next_Class=NEXT CLASS
+# The following ALL CAPS words should be translated. It is used as "Previous Package" link on javadoc.
 doclet.Prev_Package=PREV PACKAGE
+# The following ALL CAPS words should be translated. It is used as "Next Package" link on javadoc.
 doclet.Next_Package=NEXT PACKAGE
+# The following ALL CAPS words should be translated. It is used as "Previous Letter" link on javadoc alphabetical index.
 doclet.Prev_Letter=PREV LETTER
+# The following ALL CAPS words should be translated. It is used as "Next Letter" link on javadoc alphabetical index.
 doclet.Next_Letter=NEXT LETTER
+# The following ALL CAPS words should be translated. It is used as "Show List" link on javadoc.
 doclet.Show_Lists=SHOW LISTS
+# The following ALL CAPS words should be translated. It is used as "Hide List" link on javadoc.
 doclet.Hide_Lists=HIDE LISTS
 doclet.Href_Class_Title=class in {0}
 doclet.Href_Interface_Title=interface in {0}
@@ -27,16 +37,27 @@
 doclet.Href_Enum_Title=enum in {0}
 doclet.Href_Type_Param_Title=type parameter in {0}
 doclet.Href_Class_Or_Interface_Title=class or interface in {0}
+# The following ALL CAPS words should be translated. It's used as SUMMARY: NESTED | FIELD | CONSTR | METHOD, meaning Nested Class Summary, Field Summary, Constructor Summary, or Method Summary.
 doclet.Summary=SUMMARY:
+# The following ALL CAPS words should be translated. It is used as DETAIL: FIELD | CONSTR | METHOD, meaning Field Detail, Constructor Detail, or Method Detail.
 doclet.Detail=DETAIL:
+# The following ALL CAPS words should be translated. It is used as "Nested" (Nested Class Summary) link on javadoc.
 doclet.navNested=NESTED
+# The following ALL CAPS words should be translated. It is used as "Optional" (Optional Element Summary) link on javadoc.
 doclet.navAnnotationTypeOptionalMember=OPTIONAL
+# The following ALL CAPS words should be translated. It is used as "Required" (Required Element Summary) link on javadoc.
 doclet.navAnnotationTypeRequiredMember=REQUIRED
+# The following ALL CAPS words should be translated. It is used as "Element" (Required Element Summary) link on javadoc.
 doclet.navAnnotationTypeMember=ELEMENT
+# The following ALL CAPS words should be translated. It is used as "Field" (Field Detail) link on javadoc.
 doclet.navField=FIELD
+# The following ALL CAPS words should be translated. It is used as "Enum Constants" link on javadoc.
 doclet.navEnum=ENUM CONSTANTS
+# The following ALL CAPS words should be translated. It is used as "Constructor" (Constructor Detail) link on javadoc.
 doclet.navConstructor=CONSTR
+# The following ALL CAPS words should be translated. It is used as "Method" (Method Detail) link on javadoc.
 doclet.navMethod=METHOD
+# The following resource does not seem to be used anymore.
 doclet.navFactoryMethod=FACTORY
 doclet.Index=Index
 doclet.Window_Single_Index=Index
@@ -45,8 +66,11 @@
 doclet.Skip_navigation_links=Skip navigation links
 doclet.New_Page=NewPage
 doclet.None=None
+# The following resource does not seem to be used anymore
 doclet.CLASSES=CLASSES
+# The following resource does not seem to be used anymore
 doclet.MEMBERS=MEMBERS
+# The following resource does not seem to be used anymore
 doclet.NONE=NONE
 doclet.Factory_Method_Detail=Static Factory Method Detail
 doclet.navDeprecated=Deprecated
@@ -112,7 +136,9 @@
 doclet.Option=Option
 doclet.Or=Or
 doclet.Frames=Frames
+# The following ALL CAPS words should be translated. It is used as "FRAMES" javadoc navigation link to indicate displaying the page with HTML frames.
 doclet.FRAMES=FRAMES
+# The following ALL CAPS words should be translated. It is used as "NO FRAMES" javadoc navigation link to indicate displaying the page without HTML frames.
 doclet.NO_FRAMES=NO FRAMES
 doclet.Package_Hierarchies=Package Hierarchies:
 doclet.Hierarchy_For_Package=Hierarchy For Package {0}
@@ -141,7 +167,7 @@
 doclet.Help_line_1=How This API Document Is Organized
 doclet.Help_line_2=This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
 doclet.Help_line_3=The {0} page is the front page of this API document and provides a list of all packages with a summary for each.  This page can also contain an overall description of the set of packages.
-doclet.Help_line_4=Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:
+doclet.Help_line_4=Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:
 doclet.Help_line_5=Class/Interface
 doclet.Help_line_6=Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:
 doclet.Help_line_7=Class inheritance diagram
@@ -164,9 +190,10 @@
 doclet.Help_line_24=These links take you to the next or previous class, interface, package, or related page.
 doclet.Help_line_25=Frames/No Frames
 doclet.Help_line_26=These links show and hide the HTML frames.  All pages are available with or without frames.
-doclet.Help_line_27=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
-doclet.Help_line_28=The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
-doclet.Help_line_29=This help file applies to API documentation generated using the standard doclet.
+doclet.Help_line_27=The {0} link shows all classes and interfaces except non-static nested types.
+doclet.Help_line_28=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.
+doclet.Help_line_29=The <a href="constant-values.html">Constant Field Values</a> page lists the static final fields and their values.
+doclet.Help_line_30=This help file applies to API documentation generated using the standard doclet.
 doclet.Help_enum_line_1=Each enum has its own separate page with the following sections:
 doclet.Help_enum_line_2=Enum declaration
 doclet.Help_enum_line_3=Enum description
--- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/SerializedFormBuilder.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Util.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -129,19 +129,11 @@
 
     public Boolean call() {
         if (!used.getAndSet(true)) {
-            beginContext();
+            initContext();
             notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
-            try {
-                compilerMain.setFatalErrors(true);
-                result = compilerMain.compile(args, context, fileObjects, processors);
-            } finally {
-                endContext();
-            }
-            compilerMain = null;
-            args = null;
-            context = null;
-            fileObjects = null;
-            notYetEntered = null;
+            compilerMain.setFatalErrors(true);
+            result = compilerMain.compile(args, context, fileObjects, processors);
+            cleanup();
             return result == 0;
         } else {
             throw new IllegalStateException("multiple calls to method 'call'");
@@ -163,8 +155,11 @@
     }
 
     private void prepareCompiler() throws IOException {
-        if (!used.getAndSet(true)) {
-            beginContext();
+        if (used.getAndSet(true)) {
+            if (compiler == null)
+                throw new IllegalStateException();
+        } else {
+            initContext();
             compilerMain.setOptions(Options.instance(context));
             compilerMain.filenames = new ListBuffer<File>();
             List<File> filenames = compilerMain.processArgs(CommandLine.parse(args));
@@ -185,13 +180,12 @@
         }
     }
 
-    private void beginContext() {
+    private void initContext() {
         context.put(JavacTaskImpl.class, this);
         if (context.get(TaskListener.class) != null)
             context.put(TaskListener.class, (TaskListener)null);
         if (taskListener != null)
             context.put(TaskListener.class, wrap(taskListener));
-        tool.beginContext(context);
         //initialize compiler's default locale
         JavacMessages.instance(context).setCurrentLocale(locale);
     }
@@ -218,8 +212,15 @@
         };
     }
 
-    private void endContext() {
-        tool.endContext();
+    void cleanup() {
+        if (compiler != null)
+            compiler.close();
+        compiler = null;
+        compilerMain = null;
+        args = null;
+        context = null;
+        fileObjects = null;
+        notYetEntered = null;
     }
 
     /**
@@ -446,12 +447,12 @@
             }
             if (genList.isEmpty()) {
                 compiler.reportDeferredDiagnostics();
-                compiler.log.flush();
-                endContext();
+                cleanup();
             }
         }
         finally {
-            compiler.log.flush();
+            if (compiler != null)
+                compiler.log.flush();
         }
         return results;
     }
--- a/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTool.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -152,36 +152,6 @@
         return new JavacFileManager(context, true, charset);
     }
 
-    private boolean compilationInProgress = false;
-
-    /**
-     * Register that a compilation is about to start.
-     */
-    void beginContext(final 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() {
-                if (givenFileManager != null) {
-                    context.put(JavaFileManager.class, givenFileManager);
-                    return givenFileManager;
-                } else {
-                    return new JavacFileManager(context, true, null);
-                }
-            }
-        });
-    }
-
-    /**
-     * Register that a compilation is completed.
-     */
-    void endContext() {
-        compilationInProgress = false;
-    }
-
     public JavacTask getTask(Writer out,
                              JavaFileManager fileManager,
                              DiagnosticListener<? super JavaFileObject> diagnosticListener,
--- a/src/share/classes/com/sun/tools/javac/code/Flags.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Flags.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/code/Kinds.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Kinds.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/code/Scope.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Scope.java	Wed Apr 20 04:37:56 2011 +0100
@@ -74,7 +74,7 @@
 
     /** A list of scopes to be notified if items are to be removed from this scope.
      */
-    List<Scope> listeners = List.nil();
+    List<ScopeListener> listeners = List.nil();
 
     /** Use as a "not-found" result for lookup.
      * Also used to mark deleted entries in the table.
@@ -219,12 +219,27 @@
         Entry e = makeEntry(sym, old, elems, s, origin);
         table[hash] = e;
         elems = e;
+
+        //notify listeners
+        for (List<ScopeListener> l = listeners; l.nonEmpty(); l = l.tail) {
+            l.head.symbolAdded(sym, this);
+        }
     }
 
     Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) {
         return new Entry(sym, shadowed, sibling, scope);
     }
 
+
+    public interface ScopeListener {
+        public void symbolAdded(Symbol sym, Scope s);
+        public void symbolRemoved(Symbol sym, Scope s);
+    }
+
+    public void addScopeListener(ScopeListener sl) {
+        listeners = listeners.prepend(sl);
+    }
+
     /** Remove symbol from this scope.  Used when an inner class
      *  attribute tells us that the class isn't a package member.
      */
@@ -258,9 +273,9 @@
             te = te.sibling;
         }
 
-        // remove items from scopes that have done importAll
-        for (List<Scope> l = listeners; l.nonEmpty(); l = l.tail) {
-            l.head.remove(sym);
+        //notify listeners
+        for (List<ScopeListener> l = listeners; l.nonEmpty(); l = l.tail) {
+            l.head.symbolRemoved(sym, this);
         }
     }
 
@@ -393,7 +408,32 @@
                 };
             }
         };
+    }
 
+    public Iterable<Symbol> getElementsByName(Name name) {
+        return getElementsByName(name, noFilter);
+    }
+
+    public Iterable<Symbol> getElementsByName(final Name name, final Filter<Symbol> sf) {
+        return new Iterable<Symbol>() {
+            public Iterator<Symbol> iterator() {
+                 return new Iterator<Symbol>() {
+                    Scope.Entry currentEntry = lookup(name, sf);
+
+                    public boolean hasNext() {
+                        return currentEntry.scope != null;
+                    }
+                    public Symbol next() {
+                        Scope.Entry prevEntry = currentEntry;
+                        currentEntry = currentEntry.next(sf);
+                        return prevEntry.sym;
+                    }
+                    public void remove() {
+                        throw new UnsupportedOperationException();
+                    }
+                };
+            }
+        };
     }
 
     public String toString() {
@@ -488,7 +528,7 @@
         }
     }
 
-    public static class StarImportScope extends ImportScope {
+    public static class StarImportScope extends ImportScope implements ScopeListener {
 
         public StarImportScope(Symbol owner) {
             super(owner);
@@ -500,8 +540,13 @@
                     enter(e.sym, fromScope);
             }
             // Register to be notified when imported items are removed
-            fromScope.listeners = fromScope.listeners.prepend(this);
+            fromScope.addScopeListener(this);
         }
+
+        public void symbolRemoved(Symbol sym, Scope s) {
+            remove(sym);
+        }
+        public void symbolAdded(Symbol sym, Scope s) { }
     }
 
     /** An empty scope, into which you can't place anything.  Used for
@@ -538,6 +583,151 @@
         }
     }
 
+    /** A class scope adds capabilities to keep track of changes in related
+     *  class scopes - this allows client to realize whether a class scope
+     *  has changed, either directly (because a new member has been added/removed
+     *  to this scope) or indirectly (i.e. because a new member has been
+     *  added/removed into a supertype scope)
+     */
+    public static class CompoundScope extends Scope implements ScopeListener {
+
+        public static final Entry[] emptyTable = new Entry[0];
+
+        private List<Scope> subScopes = List.nil();
+        private int mark = 0;
+
+        public CompoundScope(Symbol owner) {
+            super(null, owner, emptyTable);
+        }
+
+        public void addSubScope(Scope that) {
+           if (that != null) {
+                subScopes = subScopes.prepend(that);
+                that.addScopeListener(this);
+                mark++;
+                for (ScopeListener sl : listeners) {
+                    sl.symbolAdded(null, this); //propagate upwards in case of nested CompoundScopes
+                }
+           }
+         }
+
+        public void symbolAdded(Symbol sym, Scope s) {
+            mark++;
+            for (ScopeListener sl : listeners) {
+                sl.symbolAdded(sym, s);
+            }
+        }
+
+        public void symbolRemoved(Symbol sym, Scope s) {
+            mark++;
+            for (ScopeListener sl : listeners) {
+                sl.symbolRemoved(sym, s);
+            }
+        }
+
+        public int getMark() {
+            return mark;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder buf = new StringBuilder();
+            buf.append("CompoundScope{");
+            String sep = "";
+            for (Scope s : subScopes) {
+                buf.append(sep);
+                buf.append(s);
+                sep = ",";
+            }
+            buf.append("}");
+            return buf.toString();
+        }
+
+        @Override
+        public Iterable<Symbol> getElements(final Filter<Symbol> sf) {
+            return new Iterable<Symbol>() {
+                public Iterator<Symbol> iterator() {
+                    return new CompoundScopeIterator(subScopes) {
+                        Iterator<Symbol> nextIterator(Scope s) {
+                            return s.getElements().iterator();
+                        }
+                    };
+                }
+            };
+        }
+
+        @Override
+        public Iterable<Symbol> getElementsByName(final Name name, final Filter<Symbol> sf) {
+            return new Iterable<Symbol>() {
+                public Iterator<Symbol> iterator() {
+                    return new CompoundScopeIterator(subScopes) {
+                        Iterator<Symbol> nextIterator(Scope s) {
+                            return s.getElementsByName(name, sf).iterator();
+                        }
+                    };
+                }
+            };
+        }
+
+        abstract class CompoundScopeIterator implements Iterator<Symbol> {
+
+            private Iterator<Symbol> currentIterator;
+            private List<Scope> scopesToScan;
+
+            public CompoundScopeIterator(List<Scope> scopesToScan) {
+                this.scopesToScan = scopesToScan;
+                update();
+            }
+
+            abstract Iterator<Symbol> nextIterator(Scope s);
+
+            public boolean hasNext() {
+                return currentIterator != null;
+            }
+
+            public Symbol next() {
+                Symbol sym = currentIterator.next();
+                if (!currentIterator.hasNext()) {
+                    update();
+                }
+                return sym;
+            }
+
+            public void remove() {
+                throw new UnsupportedOperationException();
+            }
+
+            private void update() {
+                while (scopesToScan.nonEmpty()) {
+                    currentIterator = nextIterator(scopesToScan.head);
+                    scopesToScan = scopesToScan.tail;
+                    if (currentIterator.hasNext()) return;
+                }
+                currentIterator = null;
+            }
+        }
+
+        @Override
+        public Entry lookup(Name name, Filter<Symbol> sf) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public Scope dup(Symbol newOwner) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void enter(Symbol sym, Scope s, Scope origin) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void remove(Symbol sym) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
     /** An error scope, for which the owner should be an error symbol. */
     public static class ErrorScope extends Scope {
         ErrorScope(Scope next, Symbol errSymbol, Entry[] table) {
--- a/src/share/classes/com/sun/tools/javac/code/Source.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Source.java	Wed Apr 20 04:37:56 2011 +0100
@@ -131,6 +131,12 @@
     public boolean allowMulticatch() {
         return compareTo(JDK1_7) >= 0;
     }
+    public boolean allowImprovedRethrowAnalysis() {
+        return compareTo(JDK1_7) >= 0;
+    }
+    public boolean allowImprovedCatchAnalysis() {
+        return compareTo(JDK1_7) >= 0;
+    }
     public boolean allowEnums() {
         return compareTo(JDK1_5) >= 0;
     }
--- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Apr 20 04:37:56 2011 +0100
@@ -731,7 +731,7 @@
 
         /** members closure cache (set by Types.membersClosure)
          */
-        Scope membersClosure;
+        Scope.CompoundScope membersClosure;
 
         public ClassSymbol(long flags, Name name, Type type, Symbol owner) {
             super(flags, name, type, owner);
@@ -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/src/share/classes/com/sun/tools/javac/code/Symtab.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Symtab.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/code/Type.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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());
@@ -270,10 +286,6 @@
     public Type              getUpperBound()     { return null; }
     public Type              getLowerBound()     { return null; }
 
-    public void setThrown(List<Type> ts) {
-        throw new AssertionError();
-    }
-
     /** Navigation methods, these will work for classes, type variables,
      *  foralls, but will return null for arrays and methods.
      */
@@ -388,14 +400,6 @@
      */
     public void complete() {}
 
-    public Object clone() {
-        try {
-            return super.clone();
-        } catch (CloneNotSupportedException e) {
-            throw new AssertionError(e);
-        }
-    }
-
     public TypeSymbol asElement() {
         return tsym;
     }
@@ -476,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);
@@ -550,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;
@@ -590,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(".");
@@ -608,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());
@@ -817,8 +825,7 @@
         }
     }
 
-    public static class MethodType extends Type
-                    implements Cloneable, ExecutableType {
+    public static class MethodType extends Type implements ExecutableType {
 
         public List<Type> argtypes;
         public Type restype;
@@ -880,10 +887,6 @@
         public Type              getReturnType()     { return restype; }
         public List<Type>        getThrownTypes()    { return thrown; }
 
-        public void setThrown(List<Type> t) {
-            thrown = t;
-        }
-
         public boolean isErroneous() {
             return
                 isErroneous(argtypes) ||
@@ -1068,12 +1071,10 @@
         public List<Type> getThrownTypes() { return qtype.getThrownTypes(); }
         public List<Type> allparams() { return qtype.allparams(); }
         public Type getUpperBound() { return qtype.getUpperBound(); }
-        public Object clone() { DelegatedType t = (DelegatedType)super.clone(); t.qtype = (Type)qtype.clone(); return t; }
         public boolean isErroneous() { return qtype.isErroneous(); }
     }
 
-    public static class ForAll extends DelegatedType
-            implements Cloneable, ExecutableType {
+    public static class ForAll extends DelegatedType implements ExecutableType {
         public List<Type> tvars;
 
         public ForAll(List<Type> tvars, Type qtype) {
@@ -1092,16 +1093,6 @@
 
         public List<Type> getTypeArguments()   { return tvars; }
 
-        public void setThrown(List<Type> t) {
-            qtype.setThrown(t);
-        }
-
-        public Object clone() {
-            ForAll result = (ForAll)super.clone();
-            result.qtype = (Type)result.qtype.clone();
-            return result;
-        }
-
         public boolean isErroneous()  {
             return qtype.isErroneous();
         }
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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);
     }
 
     /**
@@ -2023,18 +2027,22 @@
             final MethodSymbol cachedImpl;
             final Filter<Symbol> implFilter;
             final boolean checkResult;
+            final int prevMark;
 
             public Entry(MethodSymbol cachedImpl,
                     Filter<Symbol> scopeFilter,
-                    boolean checkResult) {
+                    boolean checkResult,
+                    int prevMark) {
                 this.cachedImpl = cachedImpl;
                 this.implFilter = scopeFilter;
                 this.checkResult = checkResult;
+                this.prevMark = prevMark;
             }
 
-            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) {
+            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, int mark) {
                 return this.implFilter == scopeFilter &&
-                        this.checkResult == checkResult;
+                        this.checkResult == checkResult &&
+                        this.prevMark == mark;
             }
         }
 
@@ -2046,10 +2054,11 @@
                 _map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
             }
             Entry e = cache.get(origin);
+            CompoundScope members = membersClosure(origin.type);
             if (e == null ||
-                    !e.matches(implFilter, checkResult)) {
-                MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter);
-                cache.put(origin, new Entry(impl, implFilter, checkResult));
+                    !e.matches(implFilter, checkResult, members.getMark())) {
+                MethodSymbol impl = implementationInternal(ms, origin, checkResult, implFilter);
+                cache.put(origin, new Entry(impl, implFilter, checkResult, members.getMark()));
                 return impl;
             }
             else {
@@ -2057,8 +2066,8 @@
             }
         }
 
-        private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
-            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) {
+        private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
+            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) {
                 while (t.tag == TYPEVAR)
                     t = t.getUpperBound();
                 TypeSymbol c = t.tsym;
@@ -2066,7 +2075,7 @@
                      e.scope != null;
                      e = e.next(implFilter)) {
                     if (e.sym != null &&
-                             e.sym.overrides(ms, origin, types, checkResult))
+                             e.sym.overrides(ms, origin, Types.this, checkResult))
                         return (MethodSymbol)e.sym;
                 }
             }
@@ -2082,46 +2091,35 @@
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
-    public Scope membersClosure(Type site) {
+    public CompoundScope membersClosure(Type site) {
         return membersClosure.visit(site);
     }
 
-    UnaryVisitor<Scope> membersClosure = new UnaryVisitor<Scope>() {
-
-        public Scope visitType(Type t, Void s) {
+    UnaryVisitor<CompoundScope> membersClosure = new UnaryVisitor<CompoundScope>() {
+
+        public CompoundScope visitType(Type t, Void s) {
             return null;
         }
 
         @Override
-        public Scope visitClassType(ClassType t, Void s) {
+        public CompoundScope visitClassType(ClassType t, Void s) {
             ClassSymbol csym = (ClassSymbol)t.tsym;
             if (csym.membersClosure == null) {
-                Scope membersClosure = new Scope(csym);
+                CompoundScope membersClosure = new CompoundScope(csym);
                 for (Type i : interfaces(t)) {
-                    enterAll(visit(i), membersClosure);
+                    membersClosure.addSubScope(visit(i));
                 }
-                enterAll(visit(supertype(t)), membersClosure);
-                enterAll(csym.members(), membersClosure);
+                membersClosure.addSubScope(visit(supertype(t)));
+                membersClosure.addSubScope(csym.members());
                 csym.membersClosure = membersClosure;
             }
             return csym.membersClosure;
         }
 
         @Override
-        public Scope visitTypeVar(TypeVar t, Void s) {
+        public CompoundScope visitTypeVar(TypeVar t, Void s) {
             return visit(t.getUpperBound());
         }
-
-        public void enterAll(Scope s, Scope to) {
-            if (s == null) return;
-            List<Symbol> syms = List.nil();
-            for (Scope.Entry e = s.elems ; e != null ; e = e.sibling) {
-                syms = syms.prepend(e.sym);
-            }
-            for (Symbol sym : syms) {
-                to.enter(sym);
-            }
-        }
     };
     // </editor-fold>
 
@@ -2135,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();
@@ -2153,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)
@@ -2165,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">
@@ -2413,6 +2429,38 @@
         };
     // </editor-fold>
 
+    public Type createMethodTypeWithParameters(Type original, List<Type> newParams) {
+        return original.accept(methodWithParameters, newParams);
+    }
+    // where
+        private final MapVisitor<List<Type>> methodWithParameters = new MapVisitor<List<Type>>() {
+            public Type visitType(Type t, List<Type> newParams) {
+                throw new IllegalArgumentException("Not a method type: " + t);
+            }
+            public Type visitMethodType(MethodType t, List<Type> newParams) {
+                return new MethodType(newParams, t.restype, t.thrown, t.tsym);
+            }
+            public Type visitForAll(ForAll t, List<Type> newParams) {
+                return new ForAll(t.tvars, t.qtype.accept(this, newParams));
+            }
+        };
+
+    public Type createMethodTypeWithThrown(Type original, List<Type> newThrown) {
+        return original.accept(methodWithThrown, newThrown);
+    }
+    // where
+        private final MapVisitor<List<Type>> methodWithThrown = new MapVisitor<List<Type>>() {
+            public Type visitType(Type t, List<Type> newThrown) {
+                throw new IllegalArgumentException("Not a method type: " + t);
+            }
+            public Type visitMethodType(MethodType t, List<Type> newThrown) {
+                return new MethodType(t.argtypes, t.restype, newThrown, t.tsym);
+            }
+            public Type visitForAll(ForAll t, List<Type> newThrown) {
+                return new ForAll(t.tvars, t.qtype.accept(this, newThrown));
+            }
+        };
+
     // <editor-fold defaultstate="collapsed" desc="createErrorType">
     public Type createErrorType(Type originalType) {
         return new ErrorType(originalType, syms.errSymbol);
@@ -2508,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) {
@@ -2519,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)
@@ -2806,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[])
@@ -2825,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/src/share/classes/com/sun/tools/javac/comp/Attr.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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,10 +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);
-        }
+        clazztype = chk.checkDiamond(tree, clazztype);
         chk.validate(clazz, localEnv);
         if (tree.encl != null) {
             // We have to work in this case to store
@@ -1609,10 +1606,12 @@
         List<Type> argtypes = attribArgs(tree.args, localEnv);
         List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
 
-        if (TreeInfo.isDiamond(tree)) {
+        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;
@@ -1636,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";
@@ -1852,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.
@@ -2801,7 +2774,7 @@
                                   sym.location());
                 owntype = new MethodType(owntype.getParameterTypes(),
                                          types.erasure(owntype.getReturnType()),
-                                         owntype.getThrownTypes(),
+                                         types.erasure(owntype.getThrownTypes()),
                                          syms.methodClass);
             }
             if (useVarargs) {
@@ -2975,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;
@@ -3031,6 +3004,30 @@
         throw new AssertionError();
     }
 
+    /**
+     * Attribute an env for either a top level tree or class declaration.
+     */
+    public void attrib(Env<AttrContext> env) {
+        if (env.tree.getTag() == JCTree.TOPLEVEL)
+            attribTopLevel(env);
+        else
+            attribClass(env.tree.pos(), env.enclClass.sym);
+    }
+
+    /**
+     * Attribute a top level tree. These trees are encountered when the
+     * package declaration has annotations.
+     */
+    public void attribTopLevel(Env<AttrContext> env) {
+        JCCompilationUnit toplevel = env.toplevel;
+        try {
+            annotate.flush();
+            chk.validateAnnotations(toplevel.packageAnnotations, toplevel.packge);
+        } catch (CompletionFailure ex) {
+            chk.completionError(toplevel.pos(), ex);
+        }
+    }
+
     /** Main method: attribute class definition associated with given class symbol.
      *  reporting completion failures at the given position.
      *  @param pos The source position at which completion errors are to be
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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(),
@@ -2106,32 +2092,32 @@
     void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) {
          ClashFilter cf = new ClashFilter(site);
          //for each method m1 that is a member of 'site'...
-         for (Scope.Entry e1 = types.membersClosure(site).lookup(sym.name, cf) ;
-                e1.scope != null ; e1 = e1.next(cf)) {
+         for (Symbol s1 : types.membersClosure(site).getElementsByName(sym.name, cf)) {
             //...find another method m2 that is overridden (directly or indirectly)
             //by method 'sym' in 'site'
-            for (Scope.Entry e2 = types.membersClosure(site).lookup(sym.name, cf) ;
-                    e2.scope != null ; e2 = e2.next(cf)) {
-                if (e1.sym == e2.sym || !sym.overrides(e2.sym, site.tsym, types, false)) continue;
+            for (Symbol s2 : types.membersClosure(site).getElementsByName(sym.name, cf)) {
+                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, e1.sym)) &&
-                        types.hasSameArgs(e1.sym.erasure(types), e2.sym.erasure(types))) {
+                if (!types.isSubSignature(sym.type, types.memberType(site, s1), false) &&
+                        types.hasSameArgs(s1.erasure(types), s2.erasure(types))) {
                     sym.flags_field |= CLASH;
-                    String key = e2.sym == sym ?
+                    String key = s2 == sym ?
                             "name.clash.same.erasure.no.override" :
                             "name.clash.same.erasure.no.override.1";
                     log.error(pos,
                             key,
                             sym, sym.location(),
-                            e1.sym, e1.sym.location(),
-                            e2.sym, e2.sym.location());
+                            s1, s1.location(),
+                            s2, s2.location());
                     return;
                 }
             }
         }
     }
 
+
+
     /** Check that all static methods accessible from 'site' are
      *  mutually compatible (JLS 8.4.8).
      *
@@ -2142,16 +2128,15 @@
     void checkHideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) {
         ClashFilter cf = new ClashFilter(site);
         //for each method m1 that is a member of 'site'...
-        for (Scope.Entry e = types.membersClosure(site).lookup(sym.name, cf) ;
-                e.scope != null ; e = e.next(cf)) {
+        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, e.sym)) &&
-                    types.hasSameArgs(e.sym.erasure(types), sym.erasure(types))) {
+            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",
                         sym, sym.location(),
-                        e.sym, e.sym.location());
+                        s, s.location());
                 return;
              }
          }
@@ -2667,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;
@@ -2679,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/src/share/classes/com/sun/tools/javac/comp/Flow.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Apr 20 04:37:56 2011 +0100
@@ -190,7 +190,8 @@
     private final Resolve rs;
     private Env<AttrContext> attrEnv;
     private       Lint lint;
-    private final boolean allowRethrowAnalysis;
+    private final boolean allowImprovedRethrowAnalysis;
+    private final boolean allowImprovedCatchAnalysis;
 
     public static Flow instance(Context context) {
         Flow instance = context.get(flowKey);
@@ -209,7 +210,8 @@
         lint = Lint.instance(context);
         rs = Resolve.instance(context);
         Source source = Source.instance(context);
-        allowRethrowAnalysis = source.allowMulticatch();
+        allowImprovedRethrowAnalysis = source.allowImprovedRethrowAnalysis();
+        allowImprovedCatchAnalysis = source.allowImprovedCatchAnalysis();
     }
 
     /** A flag that indicates whether the last statement could
@@ -272,7 +274,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;
@@ -314,13 +316,22 @@
         for (PendingExit exit = pendingExits.next();
              exit != null;
              exit = pendingExits.next()) {
-            boolean synthetic = classDef != null &&
-                classDef.pos == exit.tree.pos;
-            log.error(exit.tree.pos(),
-                      synthetic
-                      ? "unreported.exception.default.constructor"
-                      : "unreported.exception.need.to.catch.or.throw",
-                      exit.thrown);
+            if (classDef != null &&
+                classDef.pos == exit.tree.pos) {
+                log.error(exit.tree.pos(),
+                        "unreported.exception.default.constructor",
+                        exit.thrown);
+            } else if (exit.tree.getTag() == JCTree.VARDEF &&
+                    ((JCVariableDecl)exit.tree).sym.isResourceVariable()) {
+                log.error(exit.tree.pos(),
+                        "unreported.exception.implicit.close",
+                        exit.thrown,
+                        ((JCVariableDecl)exit.tree).sym.name);
+            } else {
+                log.error(exit.tree.pos(),
+                        "unreported.exception.need.to.catch.or.throw",
+                        exit.thrown);
+            }
         }
     }
 
@@ -664,12 +675,15 @@
             // in an anonymous class, add the set of thrown exceptions to
             // the throws clause of the synthetic constructor and propagate
             // outwards.
+            // Changing the throws clause on the fly is okay here because
+            // the anonymous constructor can't be invoked anywhere else,
+            // and its type hasn't been cached.
             if (tree.name == names.empty) {
                 for (List<JCTree> l = tree.defs; l.nonEmpty(); l = l.tail) {
                     if (TreeInfo.isInitialConstructor(l.head)) {
                         JCMethodDecl mdef = (JCMethodDecl)l.head;
                         mdef.thrown = make.Types(thrown);
-                        mdef.sym.type.setThrown(thrown);
+                        mdef.sym.type = types.createMethodTypeWithThrown(mdef.sym.type, thrown);
                     }
                 }
                 thrownPrev = chk.union(thrown, thrownPrev);
@@ -792,14 +806,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);
@@ -819,8 +835,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;
@@ -829,9 +847,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;
@@ -852,8 +870,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;
@@ -871,7 +891,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;
@@ -885,8 +905,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) {
@@ -901,13 +919,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;
@@ -980,7 +1000,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) ?
@@ -990,17 +1009,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 {
@@ -1021,14 +1041,16 @@
                             List.<Type>nil());
                     if (closeMethod.kind == MTH) {
                         for (Type t : ((MethodSymbol)closeMethod).getThrownTypes()) {
-                            markThrown(tree.body, t);
+                            markThrown(resource, t);
                         }
                     }
                 }
             }
         }
         scanStat(tree.body);
-        List<Type> thrownInTry = thrown;
+        List<Type> thrownInTry = allowImprovedCatchAnalysis ?
+            chk.union(thrown, List.of(syms.runtimeExceptionType, syms.errorType)) :
+            thrown;
         thrown = thrownPrev;
         caught = caughtPrev;
         boolean aliveEnd = alive;
@@ -1037,11 +1059,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);
+                }
             }
         }
 
@@ -1060,16 +1085,7 @@
                     ctypes = ctypes.append(exc);
                     if (types.isSameType(exc, syms.objectType))
                         continue;
-                    if (chk.subset(exc, caughtInTry)) {
-                        log.error(l.head.pos(),
-                                  "except.already.caught", exc);
-                    } else if (!chk.isUnchecked(l.head.pos(), exc) &&
-                               exc.tsym != syms.throwableType.tsym &&
-                               exc.tsym != syms.exceptionType.tsym &&
-                               !chk.intersects(exc, thrownInTry)) {
-                        log.error(l.head.pos(),
-                                  "except.never.thrown.in.try", exc);
-                    }
+                    checkCaughtType(l.head.pos(), exc, thrownInTry, caughtInTry);
                     caughtInTry = chk.incl(exc, caughtInTry);
                 }
             }
@@ -1131,7 +1147,29 @@
             while (exits.nonEmpty()) pendingExits.append(exits.next());
         }
         uninitsTry.andSet(uninitsTryPrev).andSet(uninits);
-        unrefdResources = unrefdResourcesPrev;
+    }
+
+    void checkCaughtType(DiagnosticPosition pos, Type exc, List<Type> thrownInTry, List<Type> caughtInTry) {
+        if (chk.subset(exc, caughtInTry)) {
+            log.error(pos, "except.already.caught", exc);
+        } else if (!chk.isUnchecked(pos, exc) &&
+                exc.tsym != syms.throwableType.tsym &&
+                exc.tsym != syms.exceptionType.tsym &&
+                !chk.intersects(exc, thrownInTry)) {
+            log.error(pos, "except.never.thrown.in.try", exc);
+        } else if (allowImprovedCatchAnalysis) {
+            List<Type> catchableThrownTypes = chk.intersect(List.of(exc), thrownInTry);
+            // 'catchableThrownTypes' cannnot possibly be empty - if 'exc' was an
+            // unchecked exception, the result list would not be empty, as the augmented
+            // thrown set includes { RuntimeException, Error }; if 'exc' was a checked
+            // exception, that would have been covered in the branch above
+            if (chk.diff(catchableThrownTypes, caughtInTry).isEmpty()) {
+                String key = catchableThrownTypes.length() == 1 ?
+                        "unreachable.catch" :
+                        "unreachable.catch.1";
+                log.warning(pos, key, catchableThrownTypes);
+            }
+        }
     }
 
     public void visitConditional(JCConditional tree) {
@@ -1218,7 +1256,7 @@
             sym.kind == VAR &&
             (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 &&
             preciseRethrowTypes.get(sym) != null &&
-            allowRethrowAnalysis) {
+            allowImprovedRethrowAnalysis) {
             for (Type t : preciseRethrowTypes.get(sym)) {
                 markThrown(tree, t);
             }
@@ -1357,9 +1395,7 @@
     }
 
     void referenced(Symbol sym) {
-        if (unrefdResources != null && unrefdResources.containsKey(sym)) {
-            unrefdResources.remove(sym);
-        }
+        unrefdResources.remove(sym);
     }
 
     public void visitTypeCast(JCTypeCast tree) {
@@ -1418,6 +1454,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
@@ -1432,6 +1469,7 @@
             this.make = null;
             this.thrown = this.caught = null;
             this.classDef = null;
+            unrefdResources = null;
         }
     }
 }
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/comp/Lower.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1425,25 +1425,55 @@
         }
     }
 
-    /** Optionally replace a try statement with an automatic resource
-     *  management (ARM) block.
+    /**
+     * Optionally replace a try statement with the desugaring of a
+     * try-with-resources statement.  The canonical desugaring of
+     *
+     * try ResourceSpecification
+     *   Block
+     *
+     * is
+     *
+     * {
+     *   final VariableModifiers_minus_final R #resource = Expression;
+     *   Throwable #primaryException = null;
+     *
+     *   try ResourceSpecificationtail
+     *     Block
+     *   catch (Throwable #t) {
+     *     #primaryException = t;
+     *     throw #t;
+     *   } finally {
+     *     if (#resource != null) {
+     *       if (#primaryException != null) {
+     *         try {
+     *           #resource.close();
+     *         } catch(Throwable #suppressedException) {
+     *           #primaryException.addSuppressed(#suppressedException);
+     *         }
+     *       } else {
+     *         #resource.close();
+     *       }
+     *     }
+     *   }
+     *
      * @param tree  The try statement to inspect.
-     * @return      An ARM block, or the original try block if there are no
-     *              resources to manage.
+     * @return A a desugared try-with-resources tree, or the original
+     * try block if there are no resources to manage.
      */
-    JCTree makeArmTry(JCTry tree) {
+    JCTree makeTwrTry(JCTry tree) {
         make_at(tree.pos());
         twrVars = twrVars.dup();
-        JCBlock armBlock = makeArmBlock(tree.resources, tree.body, 0);
+        JCBlock twrBlock = makeTwrBlock(tree.resources, tree.body, 0);
         if (tree.catchers.isEmpty() && tree.finalizer == null)
-            result = translate(armBlock);
+            result = translate(twrBlock);
         else
-            result = translate(make.Try(armBlock, tree.catchers, tree.finalizer));
+            result = translate(make.Try(twrBlock, tree.catchers, tree.finalizer));
         twrVars = twrVars.leave();
         return result;
     }
 
-    private JCBlock makeArmBlock(List<JCTree> resources, JCBlock block, int depth) {
+    private JCBlock makeTwrBlock(List<JCTree> resources, JCBlock block, int depth) {
         if (resources.isEmpty())
             return block;
 
@@ -1497,16 +1527,16 @@
 
         int oldPos = make.pos;
         make.at(TreeInfo.endPos(block));
-        JCBlock finallyClause = makeArmFinallyClause(primaryException, expr);
+        JCBlock finallyClause = makeTwrFinallyClause(primaryException, expr);
         make.at(oldPos);
-        JCTry outerTry = make.Try(makeArmBlock(resources.tail, block, depth + 1),
+        JCTry outerTry = make.Try(makeTwrBlock(resources.tail, block, depth + 1),
                                   List.<JCCatch>of(catchClause),
                                   finallyClause);
         stats.add(outerTry);
         return make.Block(0L, stats.toList());
     }
 
-    private JCBlock makeArmFinallyClause(Symbol primaryException, JCExpression resource) {
+    private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) {
         // primaryException.addSuppressed(catchException);
         VarSymbol catchException =
             new VarSymbol(0, make.paramName(2),
@@ -1525,22 +1555,30 @@
         List<JCCatch> catchClauses = List.<JCCatch>of(make.Catch(catchExceptionDecl, catchBlock));
         JCTry tryTree = make.Try(tryBlock, catchClauses, null);
 
-        // if (resource != null) resourceClose;
-        JCExpression nullCheck = makeBinary(JCTree.NE,
-                                            make.Ident(primaryException),
-                                            makeNull());
-        JCIf closeIfStatement = make.If(nullCheck,
+        // if (primaryException != null) {try...} else resourceClose;
+        JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)),
                                         tryTree,
                                         makeResourceCloseInvocation(resource));
-        return make.Block(0L, List.<JCStatement>of(closeIfStatement));
+
+        // if (#resource != null) { if (primaryException ...  }
+        return make.Block(0L,
+                          List.<JCStatement>of(make.If(makeNonNullCheck(resource),
+                                                       closeIfStatement,
+                                                       null)));
     }
 
     private JCStatement makeResourceCloseInvocation(JCExpression resource) {
         // create resource.close() method invocation
-        JCExpression resourceClose = makeCall(resource, names.close, List.<JCExpression>nil());
+        JCExpression resourceClose = makeCall(resource,
+                                              names.close,
+                                              List.<JCExpression>nil());
         return make.Exec(resourceClose);
     }
 
+    private JCExpression makeNonNullCheck(JCExpression expression) {
+        return makeBinary(JCTree.NE, expression, makeNull());
+    }
+
     /** Construct a tree that represents the outer instance
      *  <C.this>. Never pick the current `this'.
      *  @param pos           The source code position to be used for the tree.
@@ -2779,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);
             }
@@ -3573,7 +3611,7 @@
         if (tree.resources.isEmpty()) {
             super.visitTry(tree);
         } else {
-            result = makeArmTry(tree);
+            result = makeTwrTry(tree);
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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.
  *
@@ -776,10 +778,12 @@
                     // due to error recovery or mixing incompatible class files
                     return ambiguityError(m1, m2);
                 }
+                List<Type> allThrown = chk.intersect(mt1.getThrownTypes(), mt2.getThrownTypes());
+                Type newSig = types.createMethodTypeWithThrown(mostSpecific.type, allThrown);
                 MethodSymbol result = new MethodSymbol(
                         mostSpecific.flags(),
                         mostSpecific.name,
-                        null,
+                        newSig,
                         mostSpecific.owner) {
                     @Override
                     public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) {
@@ -789,9 +793,6 @@
                             return super.implementation(origin, types, checkResult);
                     }
                 };
-                result.type = (Type)mostSpecific.type.clone();
-                result.type.setThrown(chk.intersect(mt1.getThrownTypes(),
-                                                    mt2.getThrownTypes()));
                 return result;
             }
             if (m1SignatureMoreSpecific) return m1;
@@ -852,13 +853,8 @@
             }
             //append varargs element type as last synthetic formal
             args.append(types.elemtype(varargsTypeTo));
-            MethodSymbol msym = new MethodSymbol(to.flags_field,
-                                                 to.name,
-                                                 (Type)to.type.clone(), //see: 6990136
-                                                 to.owner);
-            MethodType mtype = msym.type.asMethodType();
-            mtype.argtypes = args.toList();
-            return msym;
+            Type mtype = types.createMethodTypeWithParameters(to.type, args.toList());
+            return new MethodSymbol(to.flags_field, to.name, mtype, to.owner);
         } else {
             return to;
         }
@@ -902,7 +898,8 @@
                           bestSoFar,
                           allowBoxing,
                           useVarargs,
-                          operator);
+                          operator,
+                          new HashSet<TypeSymbol>());
     }
     // where
     private Symbol findMethod(Env<AttrContext> env,
@@ -915,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);
@@ -948,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 &&
@@ -1742,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;
@@ -1770,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/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java	Wed Apr 20 04:37:56 2011 +0100
@@ -44,21 +44,18 @@
 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() {
-                if (singleton == null)
-                    singleton = new CacheFSInfo();
-                context.put(FSInfo.class, singleton);
-                return singleton;
+            public FSInfo make(Context c) {
+                FSInfo instance = new CacheFSInfo();
+                c.put(FSInfo.class, instance);
+                return instance;
             }
         });
     }
 
-    static CacheFSInfo singleton;
-
     public void clearCache() {
         cache.clear();
     }
--- a/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java	Wed Apr 20 04:37:56 2011 +0100
@@ -89,7 +89,7 @@
 
     private FSInfo fsInfo;
 
-    private boolean useZipFileIndex;
+    private boolean contextUseOptimizedZip;
     private ZipFileIndexCache zipFileIndexCache;
 
     private final File uninited = new File("U N I N I T E D");
@@ -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);
             }
         });
     }
@@ -164,10 +164,8 @@
 
         fsInfo = FSInfo.instance(context);
 
-        // retain check for system property for compatibility
-        useZipFileIndex = options.isUnset("useJavaUtilZip")
-                && System.getProperty("useJavaUtilZip") == null;
-        if (useZipFileIndex)
+        contextUseOptimizedZip = options.getBoolean("useOptimizedZip", true);
+        if (contextUseOptimizedZip)
             zipFileIndexCache = ZipFileIndexCache.getSharedInstance();
 
         mmappedIO = options.isSet("mmappedIO");
@@ -473,9 +471,27 @@
     private static final RelativeDirectory symbolFilePrefix
             = new RelativeDirectory("META-INF/sym/rt.jar/");
 
+    /*
+     * This method looks for a ZipFormatException and takes appropriate
+     * evasive action. If there is a failure in the fast mode then we
+     * fail over to the platform zip, and allow it to deal with a potentially
+     * non compliant zip file.
+     */
+    protected Archive openArchive(File zipFilename) throws IOException {
+        try {
+            return openArchive(zipFilename, contextUseOptimizedZip);
+        } catch (IOException ioe) {
+            if (ioe instanceof ZipFileIndex.ZipFormatException) {
+                return openArchive(zipFilename, false);
+            } else {
+                throw ioe;
+            }
+        }
+    }
+
     /** Open a new zip file directory, and cache it.
      */
-    protected Archive openArchive(File zipFileName) throws IOException {
+    private Archive openArchive(File zipFileName, boolean useOptimizedZip) throws IOException {
         File origZipFileName = zipFileName;
         if (!ignoreSymbolFile && paths.isDefaultBootClassPathRtJar(zipFileName)) {
             File file = zipFileName.getParentFile().getParentFile(); // ${java.home}
@@ -497,10 +513,9 @@
             boolean usePreindexedCache = false;
             String preindexCacheLocation = null;
 
-            if (!useZipFileIndex) {
+            if (!useOptimizedZip) {
                 zdir = new ZipFile(zipFileName);
-            }
-            else {
+            } else {
                 usePreindexedCache = options.isSet("usezipindex");
                 preindexCacheLocation = options.get("java.io.tmpdir");
                 String optCacheLoc = options.get("cachezipindexdir");
@@ -527,23 +542,22 @@
             }
 
             if (origZipFileName == zipFileName) {
-                if (!useZipFileIndex) {
+                if (!useOptimizedZip) {
                     archive = new ZipArchive(this, zdir);
                 } else {
                     archive = new ZipFileIndexArchive(this,
-                                zipFileIndexCache.getZipFileIndex(zipFileName,
+                                    zipFileIndexCache.getZipFileIndex(zipFileName,
                                     null,
                                     usePreindexedCache,
                                     preindexCacheLocation,
                                     options.isSet("writezipindexfiles")));
                 }
             } else {
-                if (!useZipFileIndex) {
+                if (!useOptimizedZip) {
                     archive = new SymbolArchive(this, origZipFileName, zdir, symbolFilePrefix);
-                }
-                else {
+                } else {
                     archive = new ZipFileIndexArchive(this,
-                                zipFileIndexCache.getZipFileIndex(zipFileName,
+                                    zipFileIndexCache.getZipFileIndex(zipFileName,
                                     symbolFilePrefix,
                                     usePreindexedCache,
                                     preindexCacheLocation,
@@ -552,6 +566,8 @@
             }
         } catch (FileNotFoundException ex) {
             archive = new MissingArchive(zipFileName);
+        } catch (ZipFileIndex.ZipFormatException zfe) {
+            throw zfe;
         } catch (IOException ex) {
             if (zipFileName.exists())
                 log.error("error.reading.file", zipFileName, getMessage(ex));
--- a/src/share/classes/com/sun/tools/javac/file/Paths.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/Paths.java	Wed Apr 20 04:37:56 2011 +0100
@@ -247,10 +247,16 @@
         public Path() { super(); }
 
         public Path addDirectories(String dirs, boolean warn) {
-            if (dirs != null)
-                for (File dir : getPathEntries(dirs))
-                    addDirectory(dir, warn);
-            return this;
+            boolean prev = expandJarClassPaths;
+            expandJarClassPaths = true;
+            try {
+                if (dirs != null)
+                    for (File dir : getPathEntries(dirs))
+                        addDirectory(dir, warn);
+                return this;
+            } finally {
+                expandJarClassPaths = prev;
+            }
         }
 
         public Path addDirectories(String dirs) {
--- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Wed Apr 20 04:37:56 2011 +0100
@@ -492,8 +492,30 @@
         public ZipDirectory(RandomAccessFile zipRandomFile, long start, long end, ZipFileIndex index) throws IOException {
             this.zipRandomFile = zipRandomFile;
             this.zipFileIndex = index;
+            hasValidHeader();
+            findCENRecord(start, end);
+        }
 
-            findCENRecord(start, end);
+        /*
+         * the zip entry signature should be at offset 0, otherwise allow the
+         * calling logic to take evasive action by throwing ZipFormatException.
+         */
+        private boolean hasValidHeader() throws IOException {
+            final long pos = zipRandomFile.getFilePointer();
+            try {
+                if (zipRandomFile.read() == 'P') {
+                    if (zipRandomFile.read() == 'K') {
+                        if (zipRandomFile.read() == 0x03) {
+                            if (zipRandomFile.read() == 0x04) {
+                                return true;
+                            }
+                        }
+                    }
+                }
+            } finally {
+                zipRandomFile.seek(pos);
+            }
+            throw new ZipFormatException("invalid zip magic");
         }
 
         /*
@@ -529,7 +551,13 @@
                     zipDir = new byte[get4ByteLittleEndian(endbuf, i + 12) + 2];
                     zipDir[0] = endbuf[i + 10];
                     zipDir[1] = endbuf[i + 11];
-                    zipRandomFile.seek(start + get4ByteLittleEndian(endbuf, i + 16));
+                    int sz = get4ByteLittleEndian(endbuf, i + 16);
+                    // a negative offset or the entries field indicates a
+                    // potential zip64 archive
+                    if (sz < 0 || get2ByteLittleEndian(zipDir, 0) == 0xffff) {
+                        throw new ZipFormatException("detected a zip64 archive");
+                    }
+                    zipRandomFile.seek(start + sz);
                     zipRandomFile.readFully(zipDir, 2, zipDir.length - 2);
                     return;
                 } else {
@@ -1127,4 +1155,18 @@
         }
     }
 
+    /*
+     * Exception primarily used to implement a failover, used exclusively here.
+     */
+
+    static final class ZipFormatException extends IOException {
+        private static final long serialVersionUID = 8000196834066748623L;
+        protected ZipFormatException(String message) {
+            super(message);
+        }
+
+        protected ZipFormatException(String message, Throwable cause) {
+            super(message, cause);
+        }
+    }
 }
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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)));
             }
         }
 
@@ -633,6 +638,19 @@
         }
     }
 
+    /** Resolve an identifier which may be the binary name of a class or
+     * the Java name of a class or package.
+     * @param name      The name to resolve
+     */
+    public Symbol resolveBinaryNameOrIdent(String name) {
+        try {
+            Name flatname = names.fromString(name.replace("/", "."));
+            return reader.loadClass(flatname);
+        } catch (CompletionFailure ignore) {
+            return resolveIdent(name);
+        }
+    }
+
     /** Resolve an identifier.
      * @param name      The identifier to resolve
      */
@@ -676,7 +694,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 +810,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 +880,7 @@
 
         if (verbose) {
             elapsed_msec = elapsed(start_msec);
-            printVerbose("total", Long.toString(elapsed_msec));
+            log.printVerbose("total", Long.toString(elapsed_msec));
         }
 
         reportDeferredDiagnostics();
@@ -963,7 +986,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 +1044,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();
@@ -1050,7 +1071,7 @@
                 } else {
                     boolean errors = false;
                     for (String nameStr : classnames) {
-                        Symbol sym = resolveIdent(nameStr);
+                        Symbol sym = resolveBinaryNameOrIdent(nameStr);
                         if (sym == null || (sym.kind == Kinds.PCK && !processPcks)) {
                             log.error("proc.cant.find.class", nameStr);
                             errors = true;
@@ -1108,9 +1129,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 +1167,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);
@@ -1154,7 +1179,7 @@
                                   env.enclClass.sym.sourcefile :
                                   env.toplevel.sourcefile);
         try {
-            attr.attribClass(env.tree.pos(), env.enclClass.sym);
+            attr.attrib(env);
             if (errorCount() > 0 && !shouldStop(CompileState.ATTR)) {
                 //if in fail-over mode, ensure that AST expression nodes
                 //are correctly initialized (e.g. they have a type/symbol)
@@ -1508,7 +1533,8 @@
         }
 
     public void reportDeferredDiagnostics() {
-        if (annotationProcessingOccurred
+        if (errorCount() == 0
+                && annotationProcessingOccurred
                 && implicitSourceFilesRead
                 && implicitSourcePolicy == ImplicitSourcePolicy.UNSET) {
             if (explicitAnnotationProcessingRequested())
@@ -1562,14 +1588,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/src/share/classes/com/sun/tools/javac/main/Main.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/main/OptionName.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/OptionName.java	Wed Apr 20 04:37:56 2011 +0100
@@ -88,6 +88,7 @@
     O("-O"),
     XJCOV("-Xjcov"),
     XD("-XD"),
+    AT("@"),
     SOURCEFILE("sourcefile");
 
     public final String optionName;
--- a/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/main/RecognizedOptions.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/model/JavacTypes.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/JavacTypes.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -73,9 +73,14 @@
 
     public Element asElement(TypeMirror t) {
         Type type = cast(Type.class, t);
-        if (type.tag != TypeTags.CLASS && type.tag != TypeTags.TYPEVAR)
-            return null;
-        return type.asElement();
+        switch (type.tag) {
+            case TypeTags.CLASS:
+            case TypeTags.ERROR:
+            case TypeTags.TYPEVAR:
+                return type.asElement();
+            default:
+                return null;
+        }
     }
 
     public boolean isSameType(TypeMirror t1, TypeMirror t2) {
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Apr 20 04:37:56 2011 +0100
@@ -2357,7 +2357,7 @@
 
         List<JCTypeParameter> typarams = typeParametersOpt();
 
-        JCTree extending = null;
+        JCExpression extending = null;
         if (S.token() == EXTENDS) {
             S.nextToken();
             extending = parseType();
--- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Wed Apr 20 04:37:56 2011 +0100
@@ -282,12 +282,6 @@
         sbuf[sp++] = ch;
     }
 
-    /** For debugging purposes: print character.
-     */
-    private void dch() {
-        System.err.print(ch); System.out.flush();
-    }
-
     /** Read next character in character or string literal and copy into sbuf.
      */
     private void scanLitChar() {
--- a/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java	Wed Apr 20 04:37:56 2011 +0100
@@ -55,6 +55,7 @@
 import com.sun.tools.javac.api.JavacTrees;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.file.FSInfo;
 import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.jvm.*;
 import com.sun.tools.javac.main.JavaCompiler;
@@ -806,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;
@@ -821,14 +820,18 @@
         /** The set of package-info files to be processed this round. */
         List<PackageSymbol> packageInfoFiles;
 
+        /** The number of Messager errors generated in this round. */
+        int nMessagerErrors;
+
         /** Create a round (common code). */
-        private Round(Context context, int number, int priorWarnings) {
+        private Round(Context context, int number, int priorErrors, int priorWarnings) {
             this.context = context;
             this.number = number;
-            this.priorWarnings = priorWarnings;
 
             compiler = JavaCompiler.instance(context);
             log = Log.instance(context);
+            log.nerrors = priorErrors;
+            log.nwarnings += priorWarnings;
             log.deferDiagnostics = true;
 
             // the following is for the benefit of JavacProcessingEnvironment.getContext()
@@ -841,7 +844,7 @@
 
         /** Create the first round. */
         Round(Context context, List<JCCompilationUnit> roots, List<ClassSymbol> classSymbols) {
-            this(context, 1, 0);
+            this(context, 1, 0, 0);
             this.roots = roots;
             genClassFiles = new HashMap<String,JavaFileObject>();
 
@@ -861,7 +864,10 @@
         /** Create a new round. */
         private Round(Round prev,
                 Set<JavaFileObject> newSourceFiles, Map<String,JavaFileObject> newClassFiles) {
-            this(prev.nextContext(), prev.number+1, prev.compiler.log.nwarnings);
+            this(prev.nextContext(),
+                    prev.number+1,
+                    prev.nMessagerErrors,
+                    prev.compiler.log.nwarnings);
             this.genClassFiles = prev.genClassFiles;
 
             List<JCCompilationUnit> parsedFiles = compiler.parseFiles(newSourceFiles);
@@ -903,8 +909,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;
@@ -1015,6 +1021,8 @@
                 if (taskListener != null)
                     taskListener.finished(new TaskEvent(TaskEvent.Kind.ANNOTATION_PROCESSING_ROUND));
             }
+
+            nMessagerErrors = messager.errorCount();
         }
 
         void showDiagnostics(boolean showAll) {
@@ -1044,7 +1052,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);
@@ -1069,6 +1077,10 @@
             if (tl != null)
                 next.put(TaskListener.class, tl);
 
+            FSInfo fsInfo = context.get(FSInfo.class);
+            if (fsInfo != null)
+                next.put(FSInfo.class, fsInfo);
+
             JavaFileManager jfm = context.get(JavaFileManager.class);
             Assert.checkNonNull(jfm);
             next.put(JavaFileManager.class, jfm);
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Apr 20 04:37:56 2011 +0100
@@ -800,6 +800,11 @@
 compiler.err.unreported.exception.default.constructor=\
     unreported exception {0} in default constructor
 
+# 0: type, 1: name
+compiler.err.unreported.exception.implicit.close=\
+    unreported exception {0}; must be caught or declared to be thrown\n\
+    exception thrown from implicit call to close() on resource variable ''{1}''
+
 compiler.err.unsupported.cross.fp.lit=\
     hexadecimal floating-point literals are not supported on this VM
 
@@ -1097,6 +1102,16 @@
     cast to {0} for a varargs call\n\
     cast to {1} for a non-varargs call and to suppress this warning
 
+# 0: list of type
+compiler.warn.unreachable.catch=\
+    unreachable catch clause\n\
+    thrown type {0} has already been caught
+
+# 0: list of type
+compiler.warn.unreachable.catch.1=\
+    unreachable catch clause\n\
+    thrown types {0} have already been caught
+
 # 0: symbol
 compiler.warn.long.SVUID=\
     serialVersionUID must be of type long in class {0}
@@ -1579,13 +1594,9 @@
 compiler.misc.diamond=\
     {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
+compiler.misc.diamond.non.generic=\
+    cannot use ''<>'' with non-generic class {0}
 
 # 0: type, 1: list of type
 compiler.misc.explicit.param.do.not.conform.to.bounds=\
@@ -1794,8 +1805,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/src/share/classes/com/sun/tools/javac/resources/javac.properties	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/javac.properties	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/BasicDiagnosticFormatter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,6 +26,7 @@
 package com.sun.tools.javac.util;
 
 import java.util.Collection;
+import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Locale;
@@ -226,17 +227,14 @@
                             DiagnosticPart.SOURCE));
             initFormat();
             initIndentation();
+            if (options.isSet("oldDiags"))
+                initOldFormat();
             String fmt = options.get("diagsFormat");
             if (fmt != null) {
-                String[] formats = fmt.split("\\|");
-                switch (formats.length) {
-                    case 3:
-                        setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]);
-                    case 2:
-                        setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]);
-                    default:
-                        setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]);
-                }
+                if (fmt.equals("OLD"))
+                    initOldFormat();
+                else
+                    initFormats(fmt);
             }
             String srcPos = null;
             if ((((srcPos = options.get("sourcePosition")) != null)) &&
@@ -280,14 +278,35 @@
             initFormat();
             initIndentation();
         }
-        //where
+
         private void initFormat() {
-            availableFormats = new HashMap<BasicFormatKind, String>();
-            setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, "%f:%l:%_%t%L%m");
-            setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, "%p%L%m");
-            setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, "%f:%_%t%L%m");
+            initFormats("%f:%l:%_%p%L%m", "%p%L%m", "%f:%_%p%L%m");
         }
-        //where
+
+        private void initOldFormat() {
+            initFormats("%f:%l:%_%t%L%m", "%p%L%m", "%f:%_%t%L%m");
+        }
+
+        private void initFormats(String pos, String nopos, String clazz) {
+            availableFormats = new EnumMap<BasicFormatKind, String>(BasicFormatKind.class);
+            setFormat(BasicFormatKind.DEFAULT_POS_FORMAT,    pos);
+            setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, nopos);
+            setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT,  clazz);
+        }
+
+        @SuppressWarnings("fallthrough")
+        private void initFormats(String fmt) {
+            String[] formats = fmt.split("\\|");
+            switch (formats.length) {
+                case 3:
+                    setFormat(BasicFormatKind.DEFAULT_CLASS_FORMAT, formats[2]);
+                case 2:
+                    setFormat(BasicFormatKind.DEFAULT_NO_POS_FORMAT, formats[1]);
+                default:
+                    setFormat(BasicFormatKind.DEFAULT_POS_FORMAT, formats[0]);
+            }
+        }
+
         private void initIndentation() {
             indentationLevels = new HashMap<DiagnosticPart, Integer>();
             setIndentation(DiagnosticPart.SUMMARY, 0);
--- a/src/share/classes/com/sun/tools/javac/util/Context.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Context.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/util/Log.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javac/util/Options.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Options.java	Wed Apr 20 04:37:56 2011 +0100
@@ -76,6 +76,22 @@
     }
 
     /**
+     * Get the boolean value for an option, patterned after Boolean.getBoolean,
+     * essentially will return true, iff the value exists and is set to "true".
+     */
+    public boolean getBoolean(String name) {
+        return getBoolean(name, false);
+    }
+
+    /**
+     * Get the boolean with a default value if the option is not set.
+     */
+    public boolean getBoolean(String name, boolean defaultValue) {
+        String value = get(name);
+        return (value == null) ? defaultValue : Boolean.parseBoolean(value);
+    }
+
+    /**
      * Check if the value for an undocumented option has been set.
      */
     public boolean isSet(String name) {
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationDescImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationValueImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/DocletInvoker.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/ExecutableMemberDocImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/FieldDocImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocTodo.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/Messager.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/Messager.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/ParameterizedTypeImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/RootDocImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/SeeTagImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/Start.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/Start.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/TypeMaker.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/WildcardTypeImpl.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/resources/javadoc.properties	Wed Apr 20 04:37:56 2011 +0100
@@ -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.
--- a/src/share/classes/javax/lang/model/element/Element.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/javax/lang/model/element/Element.java	Wed Apr 20 04:37:56 2011 +0100
@@ -197,11 +197,12 @@
      * <li> If this is a {@linkplain
      * PackageElement#getEnclosingElement package}, {@code null} is
      * returned.
-
+     *
      * <li> If this is a {@linkplain
      * TypeParameterElement#getEnclosingElement type parameter},
-     * {@code null} is returned.
-
+     * {@linkplain TypeParameterElement#getGenericElement the
+     * generic element} of the type parameter is returned.
+     *
      * </ul>
      *
      * @return the enclosing element, or {@code null} if there is none
--- a/src/share/classes/javax/lang/model/element/TypeParameterElement.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/src/share/classes/javax/lang/model/element/TypeParameterElement.java	Wed Apr 20 04:37:56 2011 +0100
@@ -64,9 +64,9 @@
     List<? extends TypeMirror> getBounds();
 
     /**
-     * Returns {@code null}.
+     * Returns the {@linkplain TypeParameterElement#getGenericElement generic element} of this type parameter.
      *
-     * @return {@code null}
+     * @return the generic element of this type parameter
      */
     @Override
     Element getEnclosingElement();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testUseOption/C.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * Class in an unnamed package.
+ */
+
+public class C {
+
+    /**
+     * Field in C.
+     */
+    public UsedInC fieldInC;
+
+    /**
+     * Method in C.
+     */
+    public UsedInC methodInC(UsedInC p) {
+        return p;
+    }
+}
--- a/test/com/sun/javadoc/testUseOption/TestUseOption.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/com/sun/javadoc/testUseOption/TestUseOption.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2004, 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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 4496290 4985072
+ * @bug 4496290 4985072 7006178
  * @summary A simple test to determine if -use works.
  * @author jamieh
  * @library ../lib/
@@ -34,7 +34,7 @@
 
 public class TestUseOption extends JavadocTester {
 
-    private static final String BUG_ID = "4496290-4985072";
+    private static final String BUG_ID = "4496290-4985072-7006178";
 
     //Input for string search tests.
     private static final String[] TEST2 = {
@@ -54,6 +54,16 @@
         "Method in C8.",
     };
 
+    private static final String[][] TEST3 = {
+        {BUG_ID + "-3" + FS + "class-use" + FS + "UsedInC.html", "Uses of <a href=" +
+                 "\"../UsedInC.html\" title=\"class in &lt;Unnamed&gt;\">" +
+                 "UsedInC</a> in <a href=\"../package-summary.html\">&lt;Unnamed&gt;</a>"
+        },
+        {BUG_ID + "-3" + FS + "package-use.html", "<td class=\"colOne\">" +
+                 "<a href=\"class-use/UsedInC.html#&lt;Unnamed&gt;\">UsedInC</a>&nbsp;</td>"
+        }
+    };
+
     private static final String[] ARGS = new String[] {
         "-d", BUG_ID, "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
     };
@@ -62,6 +72,10 @@
         "-d", BUG_ID+"-2", "-sourcepath", SRC_DIR, "-use", "pkg1", "pkg2"
     };
 
+    private static final String[] ARGS3 = new String[] {
+        "-d", BUG_ID + "-3", "-sourcepath", SRC_DIR, "-use", SRC_DIR + FS + "C.java", SRC_DIR + FS + "UsedInC.java"
+    };
+
     /**
      * The entry point of the test.
      * @param args the array of command line arguments.
@@ -93,6 +107,8 @@
             prevIndex = currentIndex;
         }
         tester.printSummary();
+        run(tester, ARGS3, TEST3, NO_TEST);
+        tester.printSummary();
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/testUseOption/UsedInC.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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.
+ */
+
+public class UsedInC
+{
+}
--- a/test/tools/apt/Compile/golden.txt	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/apt/Compile/golden.txt	Wed Apr 20 04:37:56 2011 +0100
@@ -1,6 +1,6 @@
 error: It's a mad, mad, mad, mad world
 error: Something wicked this way comes
-HelloWorld.java:2: Boring class name
+HelloWorld.java:2: error: Boring class name
 public class HelloWorld {
        ^
 3 errors
--- a/test/tools/javac/4241573/T4241573.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/4241573/T4241573.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -123,7 +123,7 @@
         if (!dir.mkdirs())
             throw new Exception("cannot create directories " + dir);
         for (String e: entries) {
-            writeFile(new File(dir, getPathForEntry(e)), getBodyForEntry(e));
+            writeFile(new File(dir, getPathForDirEntry(e)), getBodyForEntry(e));
         }
         return dir;
     }
@@ -134,7 +134,7 @@
         try {
             JarOutputStream jos = new JarOutputStream(out);
             for (String e: entries) {
-                jos.putNextEntry(new JarEntry(getPathForEntry(e)));
+                jos.putNextEntry(new JarEntry(getPathForZipEntry(e)));
                 jos.write(getBodyForEntry(e).getBytes());
             }
             jos.close();
@@ -144,11 +144,16 @@
         return jar;
     }
 
-    /** Return the path for an entry given to createDir or createJar. */
-    String getPathForEntry(String e) {
+    /** Return the path for an entry given to createDir */
+    String getPathForDirEntry(String e) {
         return e.replace(".", File.separator) + ".java";
     }
 
+    /** Return the path for an entry given to createJar. */
+    String getPathForZipEntry(String e) {
+        return e.replace(".", "/") + ".java";
+    }
+
     /** Return the body text for an entry given to createDir or createJar. */
     String getBodyForEntry(String e) {
         int sep = e.lastIndexOf(".");
--- a/test/tools/javac/4846262/Test.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/4846262/Test.out	Wed Apr 20 04:37:56 2011 +0100
@@ -1,7 +1,7 @@
-Test.java:4: not a statement
+Test.java:4: error: not a statement
         abcdefg
         ^
-Test.java:4: ';' expected
+Test.java:4: error: ';' expected
         abcdefg
                ^
 2 errors
--- a/test/tools/javac/4917091/Test255.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/4917091/Test255.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
  */
 
 /*
--- a/test/tools/javac/4917091/Test256a.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/4917091/Test256a.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
  */
 
 /*
--- a/test/tools/javac/4917091/Test256b.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/4917091/Test256b.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -16,9 +16,9 @@
  * 2 along with this work; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
  */
 
 /*
--- a/test/tools/javac/6508981/TestInferBinaryName.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/6508981/TestInferBinaryName.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -138,12 +138,10 @@
                                    boolean zipFileIndexKind)
             throws IOException {
         Context ctx = new Context();
-        // uugh, ugly back door, should be cleaned up, someday
-        if (zipFileIndexKind == USE_ZIP_FILE_INDEX)
-            System.clearProperty("useJavaUtilZip");
-        else
-            System.setProperty("useJavaUtilZip", "true");
         Options options = Options.instance(ctx);
+        options.put("useOptimizedZip",
+                Boolean.toString(zipFileIndexKind == USE_ZIP_FILE_INDEX));
+
         if (symFileKind == IGNORE_SYMBOL_FILE)
             options.put("ignore.symbol.file", "true");
         JavacFileManager fm = new JavacFileManager(ctx, false, null);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6558548/T6558548.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,300 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     6558548
+ * @summary The compiler needs to be aligned with clarified specification of throws
+ * @compile/fail/ref=T6558548_latest.out -XDrawDiagnostics T6558548.java
+ * @compile/fail/ref=T6558548_6.out -source 6 -XDrawDiagnostics T6558548.java
+ */
+
+class T6558548 {
+
+    void nothing() {}
+    void checked() throws InterruptedException {}
+    void runtime() throws IllegalArgumentException {}
+
+    void m1() {
+        try {
+            throw new java.io.FileNotFoundException();
+        }
+        catch(java.io.FileNotFoundException exc) { }
+        catch(java.io.IOException exc) { } // 6: ok; latest: unreachable
+    }
+
+    void m1a() {
+        try {
+            throw new java.io.IOException();
+        }
+        catch(java.io.FileNotFoundException exc) { }
+        catch(java.io.IOException exc) { } //ok
+    }
+
+    void m2() {
+        try {
+            nothing();
+        }
+        catch(Exception exc) { } // ok
+    }
+
+    void m3() {
+        try {
+            checked();
+        }
+        catch(Exception exc) { } //ok
+    }
+
+    void m4() {
+        try {
+            runtime();
+        }
+        catch(Exception exc) { } //ok
+    }
+
+    void m5() {
+        try {
+            nothing();
+        }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m6() {
+        try {
+            checked();
+        }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m7() {
+        try {
+            runtime();
+        }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m9() {
+        try {
+            checked();
+        }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m10() {
+        try {
+            runtime();
+        }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m11() {
+        try {
+            nothing();
+        }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m12() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Throwable exc) { } // ok
+    }
+
+    void m13() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Throwable exc) { } // ok
+    }
+
+    void m14() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Throwable exc) { } // ok
+    }
+
+    void m15() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } //ok
+    }
+
+    void m16() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m17() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m18() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(InterruptedException exc) { }
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m19() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m20() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Exception exc) { } //6: ok; latest: unreachable
+    }
+
+    void m21() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } // ok
+    }
+
+    void m22() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } // 6: ok; latest: unreachable
+    }
+
+    void m23() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Exception exc) { } // 6: ok; latest: unreachable
+    }
+
+    void m24() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m25() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m26() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m27() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(InterruptedException exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m28() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m29() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(InterruptedException exc) { } //never thrown in try
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m30() {
+        try {
+            checked();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //ok
+    }
+
+    void m31() {
+        try {
+            runtime();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m32() {
+        try {
+            nothing();
+        }
+        catch(RuntimeException exc) { }
+        catch(Error exc) { }
+        catch(Throwable exc) { } //6: ok; latest: unreachable
+    }
+
+    void m33() {
+        try {
+            checked();
+        }
+        catch(InterruptedException exc) { } //ok
+    }
+
+    void m34() {
+        try {
+            runtime();
+        }
+        catch(InterruptedException exc) { } //never thrown in try
+    }
+
+    void m35() {
+        try {
+            nothing();
+        }
+        catch(InterruptedException exc) { } //never thrown in try
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6558548/T6558548_6.out	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,9 @@
+- compiler.warn.source.no.bootclasspath: 1.6
+T6558548.java:159:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:168:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:239:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:249:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:291:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:298:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+6 errors
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/6558548/T6558548_latest.out	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,23 @@
+T6558548.java:20:9: compiler.warn.unreachable.catch: java.io.FileNotFoundException
+T6558548.java:134:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:142:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:151:9: compiler.warn.unreachable.catch.1: java.lang.InterruptedException,java.lang.RuntimeException
+T6558548.java:159:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:160:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:168:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:169:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:185:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:193:9: compiler.warn.unreachable.catch: java.lang.RuntimeException
+T6558548.java:211:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:220:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:230:9: compiler.warn.unreachable.catch.1: java.lang.InterruptedException,java.lang.RuntimeException,java.lang.Error
+T6558548.java:239:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:240:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:249:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:250:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:268:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:277:9: compiler.warn.unreachable.catch.1: java.lang.RuntimeException,java.lang.Error
+T6558548.java:291:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+T6558548.java:298:9: compiler.err.except.never.thrown.in.try: java.lang.InterruptedException
+6 errors
+15 warnings
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/7023703/T7023703neg.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/7023703/T7023703neg.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/7023703/T7023703pos.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/7024568/T7024568.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/7024568/T7024568.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/AnonStaticMember_2.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/AnonStaticMember_2.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/Diagnostics/6769027/T6769027.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/Diagnostics/6769027/T6769027.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -261,7 +261,7 @@
 
     enum PositionKind {
         NOPOS(Position.NOPOS, "- ", "error: "),
-        POS(5, "Test.java:1:6: ", "/Test.java:1: ");
+        POS(5, "Test.java:1:6: ", "/Test.java:1: error: ");
 
         int pos;
         String rawOutput;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/Diagnostics/7010608/Test.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7010608
+ * @summary the string 'error' should appear in error messages
+ */
+
+import java.io.*;
+import java.net.URI;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+
+public class Test {
+    public static void main(String... args) throws Exception {
+        new Test().run();
+    }
+
+    void run() throws Exception {
+        Locale prev = Locale.getDefault();
+        Locale.setDefault(Locale.ENGLISH);
+        try {
+            test(Arrays.<String>asList(),
+                    "myfo://test:1: error: cannot find symbol");
+            test(Arrays.asList("-XDdiagsFormat=OLD"),
+                    "myfo://test:1: cannot find symbol");
+            test(Arrays.asList("-XDoldDiags"),
+                    "myfo://test:1: cannot find symbol");
+        } finally {
+            Locale.setDefault(prev);
+        }
+    }
+
+    void test(List<String> options, String expect) throws Exception {
+        System.err.println("test: " + options);
+        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        JavaFileObject f = new MyFileObject("myfo://test", "class Bad { Missing x; }");
+        List<? extends JavaFileObject> files = Arrays.asList(f);
+        CompilationTask task = javac.getTask(pw, null, null, options, null, files);
+        boolean ok = task.call();
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (ok)
+            throw new Exception("Compilation succeeded unexpectedly");
+        if (!out.contains(expect))
+            throw new Exception("expected text not found: " + expect);
+    }
+
+    class MyFileObject extends SimpleJavaFileObject {
+        MyFileObject(String uri, String text) {
+            super(URI.create(uri), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public String getName() {
+            return uri.toString();
+        }
+        @Override
+        public String getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+        final String text;
+    }
+}
+
+
--- a/test/tools/javac/InterfaceInInner.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/InterfaceInInner.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,6 +1,6 @@
 /*
  * @test  /nodynamiccopyright/
- * @bug 4063740
+ * @bug 4063740 6969184
  * @summary Interfaces may only be declared in top level classes.
  * @author turnidge
  *
--- a/test/tools/javac/Paths/Class-Path.sh	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/Paths/Class-Path.sh	Wed Apr 20 04:37:56 2011 +0100
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# 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
@@ -24,7 +24,7 @@
 #
 
 
-# @test @(#)Class-Path.sh	1.3 03/10/31
+# @test
 # @bug 4212732
 # @summary Test handling of the Class-Path attribute in jar file manifests
 # @author Martin Buchholz
@@ -184,8 +184,8 @@
 #
 Success "$jar" cfe "Hello.jar" "Hello" Bye.class
 
-# Jar creation and update when there is no manifest and inputfiles
-specified
+# Jar creation and update when there is no manifest and inputfiles 
+# specified
 Failure "$jar" cvf "A.jar"
 Failure "$jar" uvf "A.jar"
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/Paths/Class-Path2.sh	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,111 @@
+#!/bin/sh
+#
+# 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 4212732 6485027
+# @summary Test handling of the Class-Path attribute in jar file manifests
+# @author Martin Buchholz
+#
+# @run shell Class-Path2.sh
+
+# To run this test manually, simply do ./Class-Path2.sh
+
+. ${TESTSRC-.}/Util.sh
+
+set -u
+
+Cleanup() {
+    Sys rm -rf pkg Main.java Main.class Main.jar jars
+    Sys rm -rf MANIFEST.MF A.jar B.zip
+}
+
+Cleanup
+Sys mkdir pkg
+
+#----------------------------------------------------------------
+# Create mutually referential jar files
+#----------------------------------------------------------------
+cat >pkg/A.java <<EOF
+package pkg;
+import pkg.B;
+public class A {
+    public static int f() { return B.g(); }
+    public static int g() { return 0; }
+}
+EOF
+
+cat >pkg/B.java <<EOF
+package pkg;
+import pkg.A;
+public class B {
+    public static int f() { return A.g(); }
+    public static int g() { return 0; }
+}
+EOF
+
+Sys "$javac" pkg/A.java pkg/B.java
+
+MkManifestWithClassPath "./sub/B.zip"
+Sys "$jar" cmf MANIFEST.MF A.jar pkg/A.class
+
+MkManifestWithClassPath "../A.jar"
+Sys "$jar" cmf MANIFEST.MF B.zip pkg/B.class
+
+cat >Main.java <<EOF
+import pkg.*;
+public class Main {
+    public static void main(String []a) { System.exit(A.f() + B.f()); }
+}
+EOF
+
+Sys rm -rf pkg
+
+Sys mkdir jars
+Sys mkdir jars/sub/
+Sys mv A.jar jars/.
+Sys mv B.zip jars/sub/.
+
+#
+# Test 1: Compiling 
+#
+
+Success "$javac" ${TESTTOOLVMOPTS} -cp "jars/A.jar" Main.java
+Success "$java"  ${TESTVMOPTS}     -cp "jars/A.jar${PS}." Main
+
+Success "$javac" ${TESTTOOLVMOPTS} -cp "jars/sub/B.zip"       Main.java
+Success "$java"  ${TESTVMOPTS}     -cp "jars/sub/B.zip${PS}." Main
+
+#
+# Test 2: Use of extension directories is incorrect
+#
+
+Success "$javac" ${TESTTOOLVMOPTS} -extdirs jars          -cp None Main.java
+Success "$java"  ${TESTVMOPTS}     -Djava.ext.dirs="jars" -cp .    Main
+
+Success "$javac" ${TESTTOOLVMOPTS} -extdirs jars/sub          -cp None Main.java
+Success "$java"  ${TESTVMOPTS}     -Djava.ext.dirs="jars/sub" -cp .    Main
+
+Cleanup
+
+Bottom Line
--- a/test/tools/javac/Paths/Diagnostics.sh	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/Paths/Diagnostics.sh	Wed Apr 20 04:37:56 2011 +0100
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 #
-# Copyright (c) 2003, 2006, 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
@@ -182,12 +182,12 @@
 No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -Xbootclasspath/p:classesRefRef.jar Main.java
 
 #----------------------------------------------------------------
-# Class-Path attribute ignored in extdirs or endorseddirs
+# Class-Path attribute followed in extdirs or endorseddirs
 #----------------------------------------------------------------
 Sys mkdir jars
 Sys cp -p classesRefRef.jar jars/.
-No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -extdirs      jars Main.java
-No Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -endorseddirs jars Main.java
+   Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -extdirs      jars Main.java
+   Warning "$javac" ${TESTTOOLVMOPTS} -Xlint -endorseddirs jars Main.java
 
 #----------------------------------------------------------------
 # Bad Jar file in extdirs and endorseddirs should not be ignored
--- a/test/tools/javac/QualifiedNew.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/QualifiedNew.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,6 +1,6 @@
 /*
  * @test  /nodynamiccopyright/
- * @bug 4406966
+ * @bug 4406966 6969184
  * @summary null qualifying inner instance creation should be error.
  * @author gafter
  *
--- a/test/tools/javac/T6900037.java	Sat Apr 09 00:45:10 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @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/test/tools/javac/T6900037.out	Sat Apr 09 00:45:10 2011 +0100
+++ /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
--- a/test/tools/javac/TryWithResources/ResourceInterface.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/TryWithResources/ResourceInterface.out	Wed Apr 20 04:37:56 2011 +0100
@@ -1,2 +1,2 @@
-ResourceInterface.java:38:34: compiler.err.unreported.exception.need.to.catch.or.throw: ResourceInterface.E1
+ResourceInterface.java:38:13: compiler.err.unreported.exception.implicit.close: ResourceInterface.E1, r2
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/TryWithResources/T7022711.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/TryWithResources/T7022711.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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
--- a/test/tools/javac/TryWithResources/TwrFlow.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/TryWithResources/TwrFlow.out	Wed Apr 20 04:37:56 2011 +0100
@@ -1,3 +1,3 @@
 TwrFlow.java:14:11: compiler.err.except.never.thrown.in.try: java.io.IOException
-TwrFlow.java:12:46: compiler.err.unreported.exception.need.to.catch.or.throw: CustomCloseException
+TwrFlow.java:12:13: compiler.err.unreported.exception.implicit.close: CustomCloseException, twrFlow
 2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/TryWithResources/TwrNullTests.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7020047
+ * @summary Test null handling of try-with-resources statement
+ */
+
+public class TwrNullTests {
+    /*
+     * Each try-with-resources statement generates two calls to the
+     * close method for each resource: one for when there is a primary
+     * exception present and the second for when a primary exception
+     * is absent.  The null handling of both cases needs to be
+     * checked.
+     */
+    public static void main(String... args) {
+        testNormalCompletion();
+        testNoSuppression();
+    }
+
+    /*
+     * Verify empty try-with-resources on a null resource completes
+     * normally; no NPE from the generated close call.
+     */
+    private static void testNormalCompletion() {
+        try(AutoCloseable resource = null) {
+            return; // Nothing to see here, move along.
+        } catch (Exception e) {
+            throw new AssertionError("Should not be reached", e);
+        }
+    }
+
+    /*
+     * Verify that a NPE on a null resource is <em>not</em> added as a
+     * suppressed exception to an exception from try block.
+     */
+    private static void testNoSuppression() {
+        try(AutoCloseable resource = null) {
+            throw new java.io.IOException();
+        } catch(java.io.IOException ioe) {
+            Throwable[] suppressed = ioe.getSuppressed();
+            if (suppressed.length != 0) {
+                throw new AssertionError("Non-empty suppressed exceptions",
+                                         ioe);
+            }
+        } catch (Exception e) {
+            throw new AssertionError("Should not be reached", e);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/TryWithResources/UnusedResourcesTest.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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;
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/TestAnnotationPackageInfo.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,87 @@
+/*
+ * 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 6993311
+ * @summary annotations on packages are not validated
+ */
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import javax.tools.*;
+import com.sun.source.util.*;
+
+public class TestAnnotationPackageInfo {
+    public static void main(String... args) throws Exception {
+        new TestAnnotationPackageInfo().run();
+    }
+
+    static class MyFileObject extends SimpleJavaFileObject {
+        private String text;
+        public MyFileObject(String fileName, String text) {
+            super(URI.create("myfo:/" + fileName), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+
+    public void run() throws Exception {
+        final String bootPath = System.getProperty("sun.boot.class.path");
+        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+        assert tool != null;
+
+        JavaFileObject test_java = new MyFileObject("test/Test.java",
+            "package test; public @interface Test {\n" +
+            "    public int mandatory();\n" +
+            "}\n");
+
+        JavaFileObject package_info_java = new MyFileObject("test/package-info.java",
+            "@Test package test;");
+
+        DiagnosticCollector<JavaFileObject> coll = new DiagnosticCollector<JavaFileObject>();
+
+        List<String> options = Arrays.asList("-bootclasspath",  bootPath);
+        List<? extends JavaFileObject> files = Arrays.asList(test_java, package_info_java);
+        JavacTask ct = (JavacTask)tool.getTask(null, null, coll, options, null, files);
+        ct.analyze();
+
+        String expectedCode = "compiler.err.annotation.missing.default.value";
+        List<Diagnostic<? extends JavaFileObject>> diags = coll.getDiagnostics();
+        switch (diags.size()) {
+            case 0:
+                throw new Exception("no diagnostics reported");
+            case 1:
+                String code = diags.get(0).getCode();
+                if (code.equals(expectedCode))
+                    return;
+                throw new Exception("unexpected diag: " + diags.get(0));
+            default:
+                throw new Exception("unexpected diags reported: " + diags);
+        }
+    }
+}
--- a/test/tools/javac/annotations/pos/package-info.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/annotations/pos/package-info.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 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
@@ -23,12 +23,12 @@
 
 /*
  * @test
- * @bug 4901290
+ * @bug 4901290 6993311
  * @summary Package annotations
  * @author gafter
  *
  * @compile package-info.java
  */
 
-@java.lang.annotation.Documented
+@Deprecated
 package foo.bar;
--- a/test/tools/javac/api/6411310/Test.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/api/6411310/Test.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -59,12 +59,12 @@
         test(createFileManager(), createDir("dir", entries), "p", entries);
         test(createFileManager(), createDir("a b/dir", entries), "p", entries);
 
-        for (boolean useJavaUtilZip: new boolean[] { false, true }) {
-            test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries);
-            test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries);
+        for (boolean useOptimizedZip: new boolean[] { false, true }) {
+            test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries);
+            test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries);
 
             for (boolean useSymbolFile: new boolean[] { false, true }) {
-                test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", null);
+                test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", null);
             }
         }
 
@@ -145,42 +145,20 @@
         return createFileManager(false, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip) {
-        return createFileManager(useJavaUtilZip, false);
+    JavacFileManager createFileManager(boolean useOptimizedZip) {
+        return createFileManager(useOptimizedZip, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) {
-        // javac should really not be using system properties like this
-        // -- it should really be using (hidden) options -- but until then
-        // take care to leave system properties as we find them, so as not
-        // to adversely affect other tests that might follow.
-        String prev = System.getProperty("useJavaUtilZip");
-        boolean resetProperties = false;
-        try {
-            if (useJavaUtilZip) {
-                System.setProperty("useJavaUtilZip", "true");
-                resetProperties = true;
-            } else if (System.getProperty("useJavaUtilZip") != null) {
-                System.getProperties().remove("useJavaUtilZip");
-                resetProperties = true;
-            }
+    JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
+        Context c = new Context();
+        Options options = Options.instance(c);
 
-            Context c = new Context();
-            if (!useSymbolFile) {
-                Options options = Options.instance(c);
-                options.put("ignore.symbol.file", "true");
-            }
+        options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
 
-            return new JavacFileManager(c, false, null);
-        } finally {
-            if (resetProperties) {
-                if (prev == null) {
-                    System.getProperties().remove("useJavaUtilZip");
-                } else {
-                    System.setProperty("useJavaUtilZip", prev);
-                }
-            }
+        if (!useSymbolFile) {
+            options.put("ignore.symbol.file", "true");
         }
+        return new JavacFileManager(c, false, null);
     }
 
     File createDir(String name, String... entries) throws Exception {
--- a/test/tools/javac/api/6557752/T6557752.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/api/6557752/T6557752.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -118,8 +118,9 @@
 
                 Types types = task.getTypes();
 
-                if (types.asElement(trees.getOriginalType((ErrorType)typeMirror)) != null) {
-                    throw new AssertionError("Ttypes.asElement() error!");
+                str1 = types.asElement(trees.getOriginalType((ErrorType)typeMirror)).toString();
+                if (!str1.equals("FooBar")) {
+                    throw new AssertionError("Types.asElement() error!");
                 }
                 foundError = true;
               }
--- a/test/tools/javac/api/T6838467.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/api/T6838467.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,9 @@
 import java.util.zip.*;
 import javax.tools.*;
 import com.sun.tools.javac.file.JavacFileManager;
+import com.sun.tools.javac.main.OptionName;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Options;
 
 public class T6838467 {
     boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A"));
@@ -176,33 +178,11 @@
         return fm;
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip) {
-        // javac should really not be using system properties like this
-        // -- it should really be using (hidden) options -- but until then
-        // take care to leave system properties as we find them, so as not
-        // to adversely affect other tests that might follow.
-        String prev = System.getProperty("useJavaUtilZip");
-        boolean resetProperties = false;
-        try {
-            if (useJavaUtilZip) {
-                System.setProperty("useJavaUtilZip", "true");
-                resetProperties = true;
-            } else if (System.getProperty("useJavaUtilZip") != null) {
-                System.getProperties().remove("useJavaUtilZip");
-                resetProperties = true;
-            }
-
-            Context c = new Context();
-            return new JavacFileManager(c, false, null);
-        } finally {
-            if (resetProperties) {
-                if (prev == null) {
-                    System.getProperties().remove("useJavaUtilZip");
-                } else {
-                    System.setProperty("useJavaUtilZip", prev);
-                }
-            }
-        }
+    JavacFileManager createFileManager(boolean useOptimizedZip) {
+        Context ctx = new Context();
+        Options options = Options.instance(ctx);
+        options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
+        return new JavacFileManager(ctx, false, null);
     }
 
     // create a directory containing a given set of paths
--- a/test/tools/javac/api/T6877206.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/api/T6877206.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2011 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,12 +63,12 @@
         test(createFileManager(), createDir("dir", entries), "p", entries.length);
         test(createFileManager(), createDir("a b/dir", entries), "p", entries.length);
 
-        for (boolean useJavaUtilZip: new boolean[] { false, true }) {
-            test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries.length);
-            test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries.length);
+        for (boolean useOptimizedZip: new boolean[] { false, true }) {
+            test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries.length);
+            test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries.length);
 
             for (boolean useSymbolFile: new boolean[] { false, true }) {
-                test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", -1);
+                test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", -1);
             }
         }
 
@@ -161,42 +161,18 @@
         return createFileManager(false, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip) {
-        return createFileManager(useJavaUtilZip, false);
+    JavacFileManager createFileManager(boolean useOptimizedZip) {
+        return createFileManager(useOptimizedZip, false);
     }
 
-    JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) {
-        // javac should really not be using system properties like this
-        // -- it should really be using (hidden) options -- but until then
-        // take care to leave system properties as we find them, so as not
-        // to adversely affect other tests that might follow.
-        String prev = System.getProperty("useJavaUtilZip");
-        boolean resetProperties = false;
-        try {
-            if (useJavaUtilZip) {
-                System.setProperty("useJavaUtilZip", "true");
-                resetProperties = true;
-            } else if (System.getProperty("useJavaUtilZip") != null) {
-                System.getProperties().remove("useJavaUtilZip");
-                resetProperties = true;
-            }
-
-            Context c = new Context();
-            if (!useSymbolFile) {
-                Options options = Options.instance(c);
-                options.put("ignore.symbol.file", "true");
-            }
-
-            return new JavacFileManager(c, false, null);
-        } finally {
-            if (resetProperties) {
-                if (prev == null) {
-                    System.getProperties().remove("useJavaUtilZip");
-                } else {
-                    System.setProperty("useJavaUtilZip", prev);
-                }
-            }
+    JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) {
+        Context ctx = new Context();
+        Options options = Options.instance(ctx);
+        options.put("useOptimizedZip", Boolean.toString(useOptimizedZip));
+        if (!useSymbolFile) {
+            options.put("ignore.symbol.file", "true");
         }
+        return new JavacFileManager(ctx, false, null);
     }
 
     File createDir(String name, String... entries) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/TestJavacTask_Lock.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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.
+ */
+
+/*
+ * @test
+ * @bug 7026509
+ * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+import com.sun.source.util.*;
+
+public class TestJavacTask_Lock {
+    public static void main(String... args) throws Exception {
+        new TestJavacTask_Lock().run();
+    }
+
+    enum MethodKind {
+        CALL {
+            int test(CompilationTask t) {
+                boolean ok = t.call();
+                if (!ok)
+                    throw new Error("compilation failed");
+                return 1;
+            }
+        },
+        PARSE {
+            int test(CompilationTask t) {
+                try {
+                    ((JavacTask) t).parse();
+                return 1;
+                } catch (IOException ex) {
+                    throw new Error(ex);
+                }
+            }
+
+        };
+        abstract int test(CompilationTask t);
+    }
+
+    JavaCompiler comp;
+    StandardJavaFileManager fm;
+
+    void run() throws Exception {
+        comp = ToolProvider.getSystemJavaCompiler();
+        fm = comp.getStandardFileManager(null, null, null);
+
+        for (MethodKind first: MethodKind.values()) {
+            for (MethodKind second: MethodKind.values()) {
+                test(first, second);
+            }
+        }
+
+        if (errors > 0)
+            throw new Exception(errors + " errors found");
+    }
+
+    void test(MethodKind first, MethodKind second) {
+        System.err.println("test: " + first + ", " + second);
+        File testSrc = new File(System.getProperty("test.src"));
+        String thisClassName = TestJavacTask_Lock.class.getName();
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java"));
+        File tmpDir = new File(first + "_" + second);
+        tmpDir.mkdirs();
+        List<String> options = Arrays.asList( "-d", tmpDir.getPath() );
+        CompilationTask t = comp.getTask(null, fm, null, options, null, files);
+
+        try {
+            first.test(t);
+            second.test(t);
+            error("No exception thrown");
+        } catch (IllegalStateException e) {
+            System.err.println("Expected exception caught: " + e);
+        } catch (Exception e) {
+            error("Unexpected exception caught: " + e);
+            e.printStackTrace(System.err);
+        }
+
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/TestJavacTask_Multiple.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7026509
+ * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.tools.*;
+import javax.tools.JavaCompiler.CompilationTask;
+import com.sun.source.util.*;
+
+public class TestJavacTask_Multiple {
+    public static void main(String... args) throws Exception {
+        new TestJavacTask_Multiple().run();
+    }
+
+    final int MAX_TASKS = 3;
+
+    enum TestKind {
+        CALL {
+            int test(CompilationTask t) {
+                boolean ok = t.call();
+                if (!ok)
+                    throw new Error("compilation failed");
+                return 1;
+            }
+        },
+        PARSE {
+            int test(CompilationTask t) {
+                try {
+                    ((JavacTask) t).parse();
+                return 1;
+                } catch (IOException ex) {
+                    throw new Error(ex);
+                }
+            }
+
+        };
+        abstract int test(CompilationTask t);
+    }
+
+    int count;
+
+    void run() throws Exception {
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+        for (TestKind tk: TestKind.values()) {
+            test(comp, fm, tk);
+        }
+
+        int expect = TestKind.values().length * MAX_TASKS;
+        if (count != expect) {
+            throw new Exception("Unexpected number of tests completed: " + count
+                    + ", expected: " + expect);
+        }
+
+    }
+
+    void test(JavaCompiler comp, StandardJavaFileManager fm, TestKind tk) {
+        System.err.println("test " + tk);
+        File testSrc = new File(System.getProperty("test.src"));
+        String thisClassName = TestJavacTask_Multiple.class.getName();
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java"));
+
+        List<CompilationTask> tasks = new ArrayList<CompilationTask>();
+        for (int i = 1; i <= MAX_TASKS; i++) {
+            File tmpDir = new File(tk + "_" + i);
+            tmpDir.mkdirs();
+            List<String> options = Arrays.asList( "-d", tmpDir.getPath() );
+            CompilationTask t = comp.getTask(null, fm, null, options, null, files);
+            ((JavacTask) t).setTaskListener(createTaskListener(tk, i));
+            tasks.add(t);
+        }
+
+        for (CompilationTask t: tasks)
+            count += tk.test(t);
+
+        System.err.println();
+    }
+
+    TaskListener createTaskListener(final TestKind tk, final int i) {
+        return new TaskListener() {
+
+            public void started(TaskEvent e) {
+                System.err.println(tk + "." + i + ": " + e + " started");
+            }
+
+            public void finished(TaskEvent e) {
+                System.err.println(tk + "." + i + ": " + e + " finished");
+            }
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/TestJavacTask_ParseAttrGen.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,127 @@
+/*
+ * 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 7026509
+ * @summary Cannot use JavaCompiler to create multiple CompilationTasks for partial compilations
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.lang.model.element.*;
+import javax.tools.*;
+import com.sun.source.tree.*;
+import com.sun.source.util.*;
+
+public class TestJavacTask_ParseAttrGen {
+    public static void main(String... args) throws Exception {
+        new TestJavacTask_ParseAttrGen().run();
+    }
+
+    JavaCompiler comp;
+    StandardJavaFileManager fm;
+
+    void run() throws Exception {
+        comp = ToolProvider.getSystemJavaCompiler();
+        fm = comp.getStandardFileManager(null, null, null);
+
+        final boolean[] booleanValues = { false, true };
+        for (boolean pk: booleanValues) {
+            for (boolean ak: booleanValues) {
+                for (boolean gk: booleanValues) {
+                    test(pk, ak, gk);
+                }
+            }
+        }
+    }
+
+    void test(boolean pk, boolean ak, boolean gk) throws Exception {
+        if (!pk && !ak && !gk)  // nothing to do
+            return;
+
+        System.err.println("test: pk:" + pk + ", ak:" + ak + ", gk: " + gk);
+        File testSrc = new File(System.getProperty("test.src"));
+        String thisClassName = TestJavacTask_ParseAttrGen.class.getName();
+        Iterable<? extends JavaFileObject> files =
+                fm.getJavaFileObjects(new File(testSrc, thisClassName + ".java"));
+        File tmpDir = new File((pk ? "p" : "") + (ak ? "a" : "") + (gk ? "g" : ""));
+        tmpDir.mkdirs();
+        fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(tmpDir));
+        JavacTask t = (JavacTask) comp.getTask(null, fm, null, null, null, files);
+        //t.setTaskListener(createTaskListener());
+
+        try {
+            if (pk) {
+                Iterable<? extends CompilationUnitTree> trees = t.parse();
+                System.err.println(count(trees) + " trees parsed");
+            }
+
+            if (ak) {
+                Iterable<? extends Element> elems = t.analyze();
+                System.err.println(count(elems) + " elements analyzed");
+            }
+
+            if (gk) {
+                Iterable<? extends JavaFileObject> classfiles = t.generate();
+                System.err.println(count(classfiles) + " class files generated");
+            }
+        } catch (IOException e) {
+            error("unexpected exception caught: " + e);
+        }
+
+        File[] genFiles = tmpDir.listFiles();
+        int expect = (gk ? 2 : 0); // main class and anon class for TaskListener
+        if (genFiles.length != expect)
+            error("unexpected number of files generated: " + genFiles.length
+                    + ", expected: " + expect);
+
+        System.err.println();
+    }
+
+    TaskListener createTaskListener() {
+        return new TaskListener() {
+            public void started(TaskEvent e) {
+                System.err.println(e + " started");
+            }
+
+            public void finished(TaskEvent e) {
+                System.err.println(e + " finished");
+            }
+        };
+    }
+
+    <T> int count(Iterable<T> items) {
+        int count = 0;
+        for (T item: items)
+            count++;
+        return count;
+    }
+
+    void error(String msg) {
+        System.err.println("Error: " + msg);
+        errors++;
+    }
+
+    int errors;
+}
--- a/test/tools/javac/diags/ArgTypeCompilerFactory.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/ArgTypeCompilerFactory.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/diags/CheckResourceKeys.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/CheckResourceKeys.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/diags/Example.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/Example.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/diags/examples.not-yet.txt	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples.not-yet.txt	Wed Apr 20 04:37:56 2011 +0100
@@ -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
--- a/test/tools/javac/diags/examples/CountError.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples/CountError.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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,6 +23,7 @@
 
 // key: compiler.misc.count.error
 // key: compiler.err.unreported.exception.need.to.catch.or.throw
+// key: compiler.err.error
 // run: backdoor
 
 class CountError {
--- a/test/tools/javac/diags/examples/CountErrorPlural.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples/CountErrorPlural.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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,6 +23,7 @@
 
 // key: compiler.misc.count.error.plural
 // key: compiler.err.unreported.exception.need.to.catch.or.throw
+// key: compiler.err.error
 // run: backdoor
 
 class CountErrorPlural {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/DiamondAndAnonClass.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/diags/examples/DiamondInvalidArg.java	Sat Apr 09 00:45:10 2011 +0100
+++ /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/test/tools/javac/diags/examples/DiamondInvalidArgs.java	Sat Apr 09 00:45:10 2011 +0100
+++ /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<>();
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/DiamondNonGeneric.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.misc.diamond.non.generic
+// key: compiler.err.cant.apply.diamond.1
+
+class DiamondNonGeneric {
+    String s = new String<>("foo");
+}
--- a/test/tools/javac/diags/examples/IdentifierExpected.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples/IdentifierExpected.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -25,6 +25,7 @@
 // key: compiler.err.expected
 // key: compiler.err.invalid.binary.number
 // key: compiler.misc.count.error.plural
+// key: compiler.err.error
 // run: backdoor
 
 class IdentifierExpected {
--- a/test/tools/javac/diags/examples/KindnameClass.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples/KindnameClass.java	Wed Apr 20 04:37:56 2011 +0100
@@ -25,6 +25,7 @@
 // key: compiler.err.cant.resolve.location
 // key: compiler.misc.location
 // key: compiler.misc.count.error
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameClass {
--- a/test/tools/javac/diags/examples/KindnameConstructor.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples/KindnameConstructor.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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
@@ -28,6 +28,7 @@
 // key: compiler.misc.arg.length.mismatch
 // key: compiler.misc.no.conforming.assignment.exists
 // key: compiler.misc.count.error.plural
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameConstructor {
--- a/test/tools/javac/diags/examples/KindnameMethod.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples/KindnameMethod.java	Wed Apr 20 04:37:56 2011 +0100
@@ -26,6 +26,7 @@
 // key: compiler.err.cant.resolve.location.args
 // key: compiler.misc.location
 // key: compiler.misc.count.error
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameMethod {
--- a/test/tools/javac/diags/examples/KindnameVariable.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/diags/examples/KindnameVariable.java	Wed Apr 20 04:37:56 2011 +0100
@@ -26,6 +26,7 @@
 // key: compiler.err.cant.resolve.location
 // key: compiler.misc.location
 // key: compiler.misc.count.error
+// key: compiler.err.error
 // run: backdoor
 
 class KindnameVariable {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/UnreachableCatch.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.unreachable.catch
+
+class UnreachableCatch {
+
+    void test() {
+        try {
+            throw new java.io.FileNotFoundException();
+        }
+        catch(java.io.FileNotFoundException exc) { }
+        catch(java.io.IOException exc) { } //unreachable
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/UnreachableCatch1.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.warn.unreachable.catch.1
+
+class UnreachableCatch1 {
+
+    void test() {
+        try {
+            throw new IllegalArgumentException();
+        }
+        catch(Error err) { }
+        catch(RuntimeException rex) { }
+        catch(Throwable t) { } //unreachable
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/UnreportedExceptionImplicitClose.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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.err.unreported.exception.implicit.close
+
+class UnreportedExceptionImplicitClose {
+    static class MyCloseable implements AutoCloseable {
+        public void close() throws Exception { }
+    }
+    void test() {
+        try (MyCloseable x = new MyCloseable()) {  }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/file/T7018098.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 7018098
+ * @summary CacheFSInfo persists too long
+ * @library ../lib
+ * @build JavacTestingAbstractProcessor T7018098
+ * @run main T7018098
+ */
+
+import java.io.*;
+import java.util.*;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedOptions;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+
+import com.sun.tools.javac.file.FSInfo;
+import com.sun.tools.javac.processing.JavacProcessingEnvironment;
+import com.sun.tools.javac.util.Context;
+
+@SupportedOptions("expect")
+public class T7018098 extends JavacTestingAbstractProcessor {
+    public static void main(String... args) throws Exception {
+        new T7018098().run();
+    }
+
+    static File testDir = new File("T7018098.dir");
+
+    void run() throws Exception {
+        String myName = T7018098.class.getSimpleName();
+        File testSrc = new File(System.getProperty("test.src"));
+        File file = new File(testSrc, myName + ".java");
+
+        _assert(!testDir.exists());
+
+        compile(
+            "-proc:only",
+            "-processor", myName,
+            "-Aexpect=false",
+            file.getPath());
+
+        testDir.mkdirs();
+        _assert(testDir.exists());
+
+        compile(
+            "-proc:only",
+            "-processor", myName,
+            "-Aexpect=true",
+            file.getPath());
+    }
+
+    void _assert(boolean cond) {
+        if (!cond)
+            throw new AssertionError();
+    }
+
+    void compile(String... args) throws Exception {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        int rc = com.sun.tools.javac.Main.compile(args, pw);
+        pw.close();
+        String out = sw.toString();
+        if (!out.isEmpty())
+            System.err.println(out);
+        if (rc != 0)
+            throw new Exception("compilation failed unexpectedly: rc=" + rc);
+    }
+
+    //---------------
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        Context context = ((JavacProcessingEnvironment) processingEnv).getContext();
+        FSInfo fsInfo = context.get(FSInfo.class);
+
+        round++;
+        if (round == 1) {
+            boolean expect = Boolean.valueOf(options.get("expect"));
+            checkEqual("cache result", fsInfo.isDirectory(testDir), expect);
+            initialFSInfo = fsInfo;
+        } else {
+            checkEqual("fsInfo", fsInfo, initialFSInfo);
+        }
+
+        return true;
+    }
+
+    <T> void checkEqual(String label, T actual, T expected) {
+        if (actual != expected)
+            messager.printMessage(Diagnostic.Kind.ERROR,
+                    "Unexpected value for " + label
+                    + "; expected: " + expected
+                    + "; found: " + actual);
+    }
+
+    int round = 0;
+    FSInfo initialFSInfo;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/file/zip/T6836682.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,241 @@
+/*
+ * 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 6836682 7025988
+ * @summary JavacFileManager handling of zip64 archives (Scenario A and B)
+ * @compile  -XDignore.symbol.file T6836682.java Utils.java
+ * @run main T6836682
+ */
+/*
+ * This test consists of two scenarios:
+ *
+ * Scenario A: create a jar with entries exceeding 64K, and see if the javac
+ * can handle this large jar on the classpath. Generally this test completes
+ * within a minute
+ *
+ * Scenario B: create a jar with a large enough file exceeding 4GB, and
+ * similarly test javac. This test is known to be slow and problematic on
+ * certain operating systems, thus this test can be selected by passing a
+ * property through jtreg as follows:
+ * -javaoptions=-DT6836682.testScenarioB=true.
+ * Note this test will only run iff all the disk requirements are met at runtime.
+ */
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.zip.CRC32;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class T6836682 {
+
+    private static final long GIGA = 1024 * 1024 * 1024;
+    private static final int BUFFER_LEN = Short.MAX_VALUE * 2;
+
+    static long getCount(long minlength) {
+        return (minlength / BUFFER_LEN) + 1;
+    }
+
+    static long computeCRC(long minlength) {
+        CRC32 crc = new CRC32();
+        byte[] buffer = new byte[BUFFER_LEN];
+        long count = getCount(minlength);
+        for (long i = 0; i < count; i++) {
+            crc.update(buffer);
+        }
+        return crc.getValue();
+    }
+
+    static long computeCRC(File inFile) throws IOException {
+        byte[] buffer = new byte[8192];
+        CRC32 crc = new CRC32();
+        FileInputStream fis = null;
+        BufferedInputStream bis = null;
+        try {
+            fis = new FileInputStream(inFile);
+            bis = new BufferedInputStream(fis);
+            int n = bis.read(buffer);
+            while (n > 0) {
+                crc.update(buffer, 0, n);
+                n = bis.read(buffer);
+            }
+        } finally {
+            Utils.close(bis);
+            Utils.close(fis);
+        }
+        return crc.getValue();
+    }
+
+    static void createLargeFile(OutputStream os, long minlength) throws IOException {
+        byte[] buffer = new byte[BUFFER_LEN];
+        long count = getCount(minlength);
+        for (long i = 0; i < count; i++) {
+            os.write(buffer);
+        }
+        os.flush();
+    }
+
+    static void createJarWithLargeFile(File jarFile, File javaFile,
+            long minlength) throws IOException {
+        Utils.createClassFile(javaFile, null, true);
+        File classFile = new File(Utils.getClassFileName(javaFile));
+        ZipOutputStream zos = null;
+        BufferedOutputStream bos = null;
+        FileInputStream fis = null;
+        try {
+            zos = new ZipOutputStream(new FileOutputStream(jarFile));
+            zos.setLevel(ZipOutputStream.STORED);
+            zos.setMethod(0);
+            bos = new BufferedOutputStream(zos);
+
+            ZipEntry ze = new ZipEntry("large.data");
+            ze.setCompressedSize(getCount(minlength) * BUFFER_LEN);
+            ze.setSize(getCount(minlength) * BUFFER_LEN);
+            ze.setCrc(computeCRC(minlength));
+            ze.setMethod(ZipEntry.STORED);
+            zos.putNextEntry(ze);
+            createLargeFile(bos, minlength);
+
+            ze = new ZipEntry(classFile.getName());
+            ze.setCompressedSize(classFile.length());
+            ze.setSize(classFile.length());
+            ze.setCrc(computeCRC(classFile));
+            ze.setMethod(ZipEntry.STORED);
+            zos.putNextEntry(ze);
+            fis = new FileInputStream(classFile);
+            Utils.copyStream(fis, bos);
+            bos.flush();
+            zos.closeEntry();
+        } finally {
+            Utils.close(bos);
+            Utils.close(zos);
+            Utils.close(fis);
+        }
+        // deleted to prevent accidental linkage
+        new File(Utils.getClassFileName(javaFile)).delete();
+    }
+
+    static void createLargeJar(File jarFile, File javaFile) throws IOException {
+        File classFile = new File(Utils.getClassFileName(javaFile));
+        Utils.createClassFile(javaFile, null, true);
+        ZipOutputStream zos = null;
+        FileInputStream fis = null;
+        final int MAX = Short.MAX_VALUE * 2 + 10;
+        ZipEntry ze = null;
+        try {
+            zos = new ZipOutputStream(new FileOutputStream(jarFile));
+            zos.setLevel(ZipOutputStream.STORED);
+            zos.setMethod(ZipOutputStream.STORED);
+            for (int i = 0; i < MAX ; i++) {
+                ze = new ZipEntry("X" + i + ".txt");
+                ze.setSize(0);
+                ze.setCompressedSize(0);
+                ze.setCrc(0);
+                zos.putNextEntry(ze);
+            }
+
+            // add a class file
+            ze = new ZipEntry(classFile.getName());
+            ze.setCompressedSize(classFile.length());
+            ze.setSize(classFile.length());
+            ze.setCrc(computeCRC(classFile));
+            zos.putNextEntry(ze);
+            fis = new FileInputStream(classFile);
+            Utils.copyStream(fis, zos);
+        } finally {
+            Utils.close(zos);
+            Utils.close(fis);
+        // deleted to prevent accidental linkage
+        new File(Utils.getClassFileName(javaFile)).delete();
+    }
+    }
+
+    // a jar with entries exceeding 64k + a class file for the existential test
+    public static void testScenarioA(String... args) throws IOException {
+        File largeJar = new File("large.jar");
+        File javaFile = new File("Foo.java");
+        createLargeJar(largeJar, javaFile);
+
+        File testFile = new File("Bar.java");
+        try {
+            Utils.createJavaFile(testFile, javaFile);
+            if (!Utils.compile("-doe", "-verbose", "-cp",
+                    largeJar.getAbsolutePath(), testFile.getAbsolutePath())) {
+                throw new IOException("test failed");
+            }
+        } finally {
+            Utils.deleteFile(largeJar);
+        }
+    }
+
+    // a jar with an enormous file + a class file for the existential test
+    public static void testScenarioB(String... args) throws IOException {
+        final File largeJar = new File("huge.jar");
+        final File javaFile = new File("Foo.java");
+
+        final Path path = largeJar.getAbsoluteFile().getParentFile().toPath();
+        final long available = Files.getFileStore(path).getUsableSpace();
+        final long MAX_VALUE = 0xFFFF_FFFFL;
+
+        final long absolute  = MAX_VALUE + 1L;
+        final long required  = (long)(absolute * 1.1); // pad for sundries
+        System.out.println("\tavailable: " + available / GIGA + " GB");
+        System.out.println("\trequired: " + required / GIGA + " GB");
+
+        if (available > required) {
+            createJarWithLargeFile(largeJar, javaFile, absolute);
+            File testFile = new File("Bar.java");
+            Utils.createJavaFile(testFile, javaFile);
+            try {
+                if (!Utils.compile("-doe", "-verbose", "-cp",
+                        largeJar.getAbsolutePath(), testFile.getAbsolutePath())) {
+                    throw new IOException("test failed");
+                }
+            } finally {
+                Utils.deleteFile(largeJar);
+            }
+        } else {
+            System.out.println("Warning: testScenarioB passes vacuously," +
+                    " requirements exceeds available space");
+        }
+    }
+
+    public static void main(String... args) throws IOException {
+        testScenarioA();
+        System.out.println("testScenarioA: PASS");
+        if (Boolean.getBoolean("T6836682.testScenarioB")) {
+            testScenarioB();
+            System.out.println("testScenarioB: PASS");
+        } else {
+            System.out.println("Warning: testScenarioB, large file test skipped");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/file/zip/T6865530.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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 6865530
+ * @summary ensure JavacFileManager handles non-standard zipfiles.
+ * @compile  -XDignore.symbol.file T6865530.java
+ * @run main T6865530
+ */
+
+
+import java.io.File;
+
+
+public class T6865530 {
+
+    public static void main(String... args) throws Exception {
+        File badFile = new File("bad.exe");
+        File testJar = new File("test.jar");
+        File fooJava = new File("Foo.java");
+        File barJava = new File("Bar.java");
+
+        // create a jar by compiling a file, and append the jar to some
+        // arbitrary data to offset the start of the zip/jar archive
+        Utils.createJavaFile(fooJava);
+        Utils.compile("-doe", "-verbose", fooJava.getName());
+        String[] jarArgs = {
+            "cvf", testJar.getAbsolutePath(), "Foo.class"
+        };
+        Utils.jarTool.run(jarArgs);
+        Utils.cat(badFile, fooJava, testJar);
+
+        // create test file and use the above file as a classpath
+        Utils.createJavaFile(barJava);
+        try {
+            if (!Utils.compile("-doe", "-verbose", "-cp", badFile.getAbsolutePath(), "Bar.java")) {
+                throw new RuntimeException("test fails javac did not compile");
+            }
+        } finally {
+            Utils.deleteFile(badFile);
+            Utils.deleteFile(testJar);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/file/zip/Utils.java	Wed Apr 20 04:37:56 2011 +0100
@@ -0,0 +1,131 @@
+/*
+ * 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.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+public class Utils {
+
+    static final sun.tools.jar.Main jarTool =
+            new sun.tools.jar.Main(System.out, System.err, "jar-tool");
+
+    static final com.sun.tools.javac.Main javac =
+            new com.sun.tools.javac.Main();
+
+    private Utils(){}
+
+    public static boolean compile(String... args) {
+        return javac.compile(args) == 0;
+    }
+
+    public static void createClassFile(File javaFile, File superClass,
+            boolean delete) throws IOException {
+        createJavaFile(javaFile, superClass);
+        if (!compile(javaFile.getName())) {
+            throw new RuntimeException("compile failed unexpectedly");
+        }
+        if (delete) javaFile.delete();
+    }
+
+    public static void createJavaFile(File outFile) throws IOException {
+        createJavaFile(outFile, null);
+    }
+
+    public static void createJavaFile(File outFile, File superClass) throws IOException {
+        PrintStream ps = null;
+        String srcStr = "public class " + getSimpleName(outFile) + " ";
+        if (superClass != null) {
+            srcStr = srcStr.concat("extends " + getSimpleName(superClass) + " ");
+        }
+        srcStr = srcStr.concat("{}");
+        try {
+            FileOutputStream fos = new FileOutputStream(outFile);
+            ps = new PrintStream(fos);
+            ps.println(srcStr);
+        } finally {
+            close(ps);
+        }
+    }
+
+    static String getClassFileName(File javaFile) {
+        return javaFile.getName().endsWith(".java")
+                ? javaFile.getName().replace(".java", ".class")
+                : null;
+    }
+
+    static String getSimpleName(File inFile) {
+        String fname = inFile.getName();
+        return fname.substring(0, fname.indexOf("."));
+    }
+
+    public static void copyStream(InputStream in, OutputStream out) throws IOException {
+        byte[] buf = new byte[8192];
+        int n = in.read(buf);
+        while (n > 0) {
+            out.write(buf, 0, n);
+            n = in.read(buf);
+        }
+    }
+
+    public static void close(Closeable c) {
+        if (c != null) {
+            try {
+                c.close();
+            } catch (IOException ignore) {}
+        }
+    }
+
+    public static void deleteFile(File f) {
+        if (!f.delete()) {
+            throw new RuntimeException("could not delete file: " + f.getAbsolutePath());
+        }
+    }
+
+    public static void cat(File output, File... files) throws IOException {
+        BufferedInputStream bis = null;
+        BufferedOutputStream bos = null;
+        FileOutputStream fos = null;
+        try {
+            fos = new FileOutputStream(output);
+            bos = new BufferedOutputStream(fos);
+            for (File x : files) {
+                FileInputStream fis = new FileInputStream(x);
+                bis = new BufferedInputStream(fis);
+                copyStream(bis, bos);
+                Utils.close(bis);
+            }
+        } finally {
+            Utils.close(bis);
+            Utils.close(bos);
+            Utils.close(fos);
+        }
+    }
+}
--- a/test/tools/javac/generics/6969184/T6969184.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/6969184/T6969184.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7015430/T7015430.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7015430/T7015430.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7020657/T7020657neg.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7020657/T7020657neg.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7020657/T7020657pos.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7022054/T7022054neg1.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7022054/T7022054neg1.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7022054/T7022054neg2.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7022054/T7022054neg2.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7022054/T7022054pos1.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/7022054/T7022054pos2.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/6996914/T6996914a.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/6996914/T6996914a.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/6996914/T6996914b.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/6996914/T6996914b.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/T6939780.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/T6939780.java	Wed Apr 20 04:37:56 2011 +0100
@@ -1,6 +1,6 @@
 /*
  * @test /nodynamiccopyright/
- * @bug 6939780
+ * @bug 6939780 7020044
  *
  * @summary  add a warning to detect diamond sites
  * @author mcimadamore
--- a/test/tools/javac/generics/diamond/T6939780.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/T6939780.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg01.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg01.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg01.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg01.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg02.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg02.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg02.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg02.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg03.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg03.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg03.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg03.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg04.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg04.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg04.out	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg04.out	Wed Apr 20 04:37:56 2011 +0100
@@ -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/test/tools/javac/generics/diamond/neg/Neg05.java	Sat Apr 09 00:45:10 2011 +0100
+++ b/test/tools/javac/generics/diamond/neg/Neg05.java	Wed Apr 20 04:37:56 2011 +0100
@@ -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 @@