changeset 1163:dbb3f73bbe95

Merge from main OpenJDK Update 2 repository
author Greg Lewis <glewis@eyesbeyond.com>
date Sun, 26 Feb 2012 16:05:18 -0800
parents 23aadf169f08 d50e571b8d00
children ba8596eef947
files
diffstat 73 files changed, 2794 insertions(+), 218 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Jul 14 21:53:20 2011 -0400
+++ b/.hgtags	Sun Feb 26 16:05:18 2012 -0800
@@ -121,4 +121,23 @@
 8eb952f43b117d538f6ca5e9e43ff9ce7646c7ee jdk7-b144
 c455e2ae5c93014ae3fc475aba4509b5f70465f7 jdk7-b145
 9425dd4f53d5bfcd992d9aecea0eb7d8b2d4f62b jdk7-b146
+d34578643d1c6c752d4a6b5e79c6ab1b60850b4a jdk7u1-b01
 58bc532d63418ac3c9b42460d89cdaf595c6f3e1 jdk7-b147
+cd2cc8b5edb045b950aed46d159b4fb8fc2fd1df jdk7u1-b02
+82820a30201dbf4b80f1916f3d0f4a92ad21b61a jdk7u1-b03
+baa2c13c70fea3d6e259a34f0903197fdceb64b5 jdk7u1-b04
+7e0f2dcbf41ecbf61475e13ea32436e80f39b513 jdk7u1-b05
+ce654f4ecfd8fd5f81618c7e0949f22db08de4d5 jdk7u2-b01
+d5d8654d8180dc31a746253e11ac2747292154b4 jdk7u2-b04
+1f1c1763ac31e5e1264b0784f48e75cc109e60f4 jdk7u2-b05
+4c5514d422c43e23af2437001ae0595d62b6cb19 jdk7u2-b06
+0959cd580bf5748a3dfc5c431483d2abef7dd875 jdk7u2-b07
+16e34b70cea7fd68ac0aef5f2f56ea6245e4582f jdk7u2-b08
+c91ffd7f2c3fa619d4d2228f16f85a4f5aa13914 jdk7u2-b09
+5935f69f4e558d2bc88c20c55f3de54a457fd26b jdk7u1-b06
+ef15185867cf89e606239f216ff34154ce50563b jdk7u1-b07
+ee94565d9f57ee9885e3af44891877163b637cc3 jdk7u1-b08
+d37897312d318c18b0a855ce80f70c410865d105 jdk7u2-b11
+f0802d8a0909f66ce19d3d44b33ddf4943aee076 jdk7u2-b12
+f474527e77e4797d78bd6c3b31923fddcfd9d5c6 jdk7u2-b13
+fc0769df8cd03fffc38c7a1ab6b2e2e7cc2506a8 jdk7u2-b21
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.jcheck/conf	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,2 @@
+project=jdk7
+bugids=dup
--- a/THIRD_PARTY_README	Thu Jul 14 21:53:20 2011 -0400
+++ b/THIRD_PARTY_README	Sun Feb 26 16:05:18 2012 -0800
@@ -216,15 +216,16 @@
 is included with JRE 7, JDK 7, and OpenJDK 7.
 
 You are receiving a copy of the Elliptic Curve Cryptography library in source
-form with the JDK 7 source distribution and object code in the JRE 7 & JDK 7
-runtime.
-
-The terms of the Oracle license do NOT apply to the Elliptic Curve
-Cryptography library program; it is licensed under the following license,
-separately from the Oracle programs you receive. If you do not wish to install
-this program, you may delete the library named libsunec.so (on Solaris and
-Linux systems) or sunec.dll (on Windows systems) from the JRE bin directory
-reserved for native libraries.
+form with the JDK 7 and OpenJDK7 source distributions, and as object code in
+the JRE 7 & JDK 7 runtimes.
+
+In the case of the JRE 7 & JDK 7 runtimes, the terms of the Oracle license do
+NOT apply to the Elliptic Curve Cryptography library; it is licensed under the
+following license, separately from Oracle's JDK & JRE.  If you do not wish to
+install the Elliptic Curve Cryptography library, you may delete the library
+named libsunec.so (on Solaris and Linux systems) or sunec.dll (on Windows
+systems) from the JRE bin directory reserved for native libraries.
+
 
 --- begin of LICENSE ---
 
@@ -1000,7 +1001,7 @@
 
 -------------------------------------------------------------------------------
 
-%% This notice is provided with respect to libpng 1.2.18, which is 
+%% This notice is provided with respect to libpng 1.5.4, which is 
 included with JRE 7, JDK 7, and OpenJDK 7.
 
 --- begin of LICENSE ---
@@ -1014,8 +1015,10 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.2.6, August 15, 2004, through 1.2.18, May 15, 2007, are
-Copyright (c) 2004, 2006-2007 Glenn Randers-Pehrson, and are
+This code is released under the libpng license.
+
+libpng versions 1.2.6, August 15, 2004, through 1.5.4, July 7, 2011, are
+Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
 
@@ -1112,7 +1115,7 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-May 15, 2007
+July 7, 2011
 
 --- end of LICENSE ---
 
--- a/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java	Sun Feb 26 16:05:18 2012 -0800
@@ -37,6 +37,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
 
@@ -51,6 +52,7 @@
 import com.sun.source.util.TaskListener;
 import com.sun.tools.javac.util.ClientCodeException;
 import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic;
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
@@ -146,7 +148,7 @@
             return fo;
     }
 
-    <T> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) {
+    <T /*super JavaFileOject*/> DiagnosticListener<T> wrap(DiagnosticListener<T> dl) {
         if (isTrusted(dl))
             return dl;
         return new WrappedDiagnosticListener<T>(dl);
@@ -158,6 +160,16 @@
         return new WrappedTaskListener(tl);
     }
 
+    @SuppressWarnings("unchecked")
+    private <T> Diagnostic<T> unwrap(final Diagnostic<T> diagnostic) {
+        if (diagnostic instanceof JCDiagnostic) {
+            JCDiagnostic d = (JCDiagnostic) diagnostic;
+            return (Diagnostic<T>) new DiagnosticSourceUnwrapper(d);
+        } else {
+            return diagnostic;
+        }
+    }
+
     protected boolean isTrusted(Object o) {
         Class<?> c = o.getClass();
         Boolean trusted = trustedClasses.get(c);
@@ -534,7 +546,7 @@
         }
     }
 
-    protected class WrappedDiagnosticListener<T> implements DiagnosticListener<T> {
+    protected class WrappedDiagnosticListener<T /*super JavaFileObject*/> implements DiagnosticListener<T> {
         protected DiagnosticListener<T> clientDiagnosticListener;
         WrappedDiagnosticListener(DiagnosticListener<T> clientDiagnosticListener) {
             clientDiagnosticListener.getClass(); // null check
@@ -544,7 +556,7 @@
         @Override
         public void report(Diagnostic<? extends T> diagnostic) {
             try {
-                clientDiagnosticListener.report(diagnostic);
+                clientDiagnosticListener.report(unwrap(diagnostic));
             } catch (ClientCodeException e) {
                 throw e;
             } catch (RuntimeException e) {
@@ -555,6 +567,54 @@
         }
     }
 
+    public class DiagnosticSourceUnwrapper implements Diagnostic<JavaFileObject> {
+        public final JCDiagnostic d;
+
+        DiagnosticSourceUnwrapper(JCDiagnostic d) {
+            this.d = d;
+        }
+
+        public Diagnostic.Kind getKind() {
+            return d.getKind();
+        }
+
+        public JavaFileObject getSource() {
+            return unwrap(d.getSource());
+        }
+
+        public long getPosition() {
+            return d.getPosition();
+        }
+
+        public long getStartPosition() {
+            return d.getStartPosition();
+        }
+
+        public long getEndPosition() {
+            return d.getEndPosition();
+        }
+
+        public long getLineNumber() {
+            return d.getLineNumber();
+        }
+
+        public long getColumnNumber() {
+            return d.getColumnNumber();
+        }
+
+        public String getCode() {
+            return d.getCode();
+        }
+
+        public String getMessage(Locale locale) {
+            return d.getMessage(locale);
+        }
+
+        public String toString() {
+            return d.toString();
+        }
+    }
+
     protected class WrappedTaskListener implements TaskListener {
         protected TaskListener clientTaskListener;
         WrappedTaskListener(TaskListener clientTaskListener) {
--- a/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -158,10 +158,10 @@
         } else {
             initContext();
             compilerMain.setOptions(Options.instance(context));
-            compilerMain.filenames = new ListBuffer<File>();
-            List<File> filenames = compilerMain.processArgs(CommandLine.parse(args));
+            compilerMain.filenames = new LinkedHashSet<File>();
+            Collection<File> filenames = compilerMain.processArgs(CommandLine.parse(args));
             if (!filenames.isEmpty())
-                throw new IllegalArgumentException("Malformed arguments " + filenames.toString(" "));
+                throw new IllegalArgumentException("Malformed arguments " + toString(filenames, " "));
             compiler = JavaCompiler.instance(context);
             compiler.keepComments = true;
             compiler.genEndPos = true;
@@ -177,6 +177,17 @@
         }
     }
 
+    <T> String toString(Iterable<T> items, String sep) {
+        String currSep = "";
+        StringBuilder sb = new StringBuilder();
+        for (T item: items) {
+            sb.append(currSep);
+            sb.append(item.toString());
+            currSep = sep;
+        }
+        return sb.toString();
+    }
+
     private void initContext() {
         context.put(JavacTaskImpl.class, this);
         if (context.get(TaskListener.class) != null)
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Sun Feb 26 16:05:18 2012 -0800
@@ -594,7 +594,15 @@
             lintEnv = lintEnv.next;
 
         // Having found the enclosing lint value, we can initialize the lint value for this class
-        env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.attributes_field, env.info.enclVar.flags());
+        // ... but ...
+        // There's a problem with evaluating annotations in the right order, such that
+        // env.info.enclVar.attributes_field might not yet have been evaluated, and so might be
+        // null. In that case, calling augment will throw an NPE. To avoid this, for now we
+        // revert to the jdk 6 behavior and ignore the (unevaluated) attributes.
+        if (env.info.enclVar.attributes_field == null)
+            env.info.lint = lintEnv.info.lint;
+        else
+            env.info.lint = lintEnv.info.lint.augment(env.info.enclVar.attributes_field, env.info.enclVar.flags());
 
         Lint prevLint = chk.setLint(env.info.lint);
         JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
@@ -1837,7 +1845,7 @@
         try {
             constructor = rs.resolveDiamond(tree.pos(),
                     localEnv,
-                    clazztype.tsym.type,
+                    clazztype,
                     argtypes,
                     typeargtypes);
         } finally {
@@ -2872,8 +2880,10 @@
 
         if (clazztype.tag == CLASS) {
             List<Type> formals = clazztype.tsym.type.getTypeArguments();
-
-            if (actuals.length() == formals.length() || actuals.length() == 0) {
+            if (actuals.isEmpty()) //diamond
+                actuals = formals;
+
+            if (actuals.length() == formals.length()) {
                 List<Type> a = actuals;
                 List<Type> f = formals;
                 while (a.nonEmpty()) {
@@ -3388,6 +3398,13 @@
         }
 
         @Override
+        public void visitAssignop(JCAssignOp that) {
+            if (that.operator == null)
+                that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
+            super.visitAssignop(that);
+        }
+
+        @Override
         public void visitBinary(JCBinary that) {
             if (that.operator == null)
                 that.operator = new OperatorSymbol(names.empty, syms.unknownType, -1, syms.noSymbol);
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Sun Feb 26 16:05:18 2012 -0800
@@ -3450,6 +3450,7 @@
                 JCExpression expression = oneCase.getExpression();
 
                 if (expression != null) { // expression for a "default" case is null
+                    expression = TreeInfo.skipParens(expression);
                     String labelExpr = (String) expression.type.constValue();
                     Integer mapping = caseLabelToPosition.put(labelExpr, casePosition);
                     Assert.checkNull(mapping);
@@ -3555,8 +3556,8 @@
                 if (isDefault)
                     caseExpr = null;
                 else {
-                    caseExpr = make.Literal(caseLabelToPosition.get((String)oneCase.
-                                                                    getExpression().
+                    caseExpr = make.Literal(caseLabelToPosition.get((String)TreeInfo.skipParens(oneCase.
+                                                                                                getExpression()).
                                                                     type.constValue()));
                 }
 
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Sun Feb 26 16:05:18 2012 -0800
@@ -691,6 +691,7 @@
             case ABSENT_MTH:
                 return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
             case WRONG_MTH:
+                if (operator) return bestSoFar;
                 wrongMethods.addCandidate(currentStep, wrongMethod.sym, wrongMethod.explanation);
             case WRONG_MTHS:
                 return wrongMethods.addCandidate(currentStep, sym, ex.getDiagnostic());
@@ -767,16 +768,13 @@
                                        m2.erasure(types).getParameterTypes()))
                     return ambiguityError(m1, m2);
                 // both abstract, neither overridden; merge throws clause and result type
-                Symbol mostSpecific;
-                if (types.returnTypeSubstitutable(mt1, mt2))
-                    mostSpecific = m1;
-                else if (types.returnTypeSubstitutable(mt2, mt1))
-                    mostSpecific = m2;
-                else {
+                Type mst = mostSpecificReturnType(mt1, mt2);
+                if (mst == null) {
                     // Theoretically, this can't happen, but it is possible
                     // due to error recovery or mixing incompatible class files
                     return ambiguityError(m1, m2);
                 }
+                Symbol mostSpecific = mst == mt1 ? m1 : m2;
                 List<Type> allThrown = chk.intersect(mt1.getThrownTypes(), mt2.getThrownTypes());
                 Type newSig = types.createMethodTypeWithThrown(mostSpecific.type, allThrown);
                 MethodSymbol result = new MethodSymbol(
@@ -859,6 +857,28 @@
         }
     }
     //where
+    Type mostSpecificReturnType(Type mt1, Type mt2) {
+        Type rt1 = mt1.getReturnType();
+        Type rt2 = mt2.getReturnType();
+
+        if (mt1.tag == FORALL && mt2.tag == FORALL) {
+            //if both are generic methods, adjust return type ahead of subtyping check
+            rt1 = types.subst(rt1, mt1.getTypeArguments(), mt2.getTypeArguments());
+        }
+        //first use subtyping, then return type substitutability
+        if (types.isSubtype(rt1, rt2)) {
+            return mt1;
+        } else if (types.isSubtype(rt2, rt1)) {
+            return mt2;
+        } else if (types.returnTypeSubstitutable(mt1, mt2)) {
+            return mt1;
+        } else if (types.returnTypeSubstitutable(mt2, mt1)) {
+            return mt2;
+        } else {
+            return null;
+        }
+    }
+    //where
     Symbol ambiguityError(Symbol m1, Symbol m2) {
         if (((m1.flags() | m2.flags()) & CLASH) != 0) {
             return (m1.flags() & CLASH) == 0 ? m1 : m2;
@@ -1666,6 +1686,7 @@
      */
     Symbol resolveOperator(DiagnosticPosition pos, int optag,
                            Env<AttrContext> env, List<Type> argtypes) {
+        startResolution();
         Name name = treeinfo.operatorName(optag);
         Symbol sym = findMethod(env, syms.predefClass.type, name, argtypes,
                                 null, false, false, true);
--- a/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/file/RegularFileObject.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2009, 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
@@ -98,6 +98,7 @@
 
     @Override
     public OutputStream openOutputStream() throws IOException {
+        fileManager.flushCache(this);
         ensureParentDirectoriesExist();
         return new FileOutputStream(file);
     }
@@ -128,6 +129,7 @@
 
     @Override
     public Writer openWriter() throws IOException {
+        fileManager.flushCache(this);
         ensureParentDirectoriesExist();
         return new OutputStreamWriter(new FileOutputStream(file), fileManager.getEncodingName());
     }
--- a/src/share/classes/com/sun/tools/javac/main/Main.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/main/Main.java	Sun Feb 26 16:05:18 2012 -0800
@@ -31,7 +31,10 @@
 import java.net.URL;
 import java.security.DigestInputStream;
 import java.security.MessageDigest;
+import java.util.Collection;
+import java.util.LinkedHashSet;
 import java.util.MissingResourceException;
+import java.util.Set;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
 import javax.annotation.processing.Processor;
@@ -107,8 +110,7 @@
         }
 
         public void addFile(File f) {
-            if (!filenames.contains(f))
-                filenames.append(f);
+            filenames.add(f);
         }
 
         public void addClassName(String s) {
@@ -136,7 +138,7 @@
 
     /** The list of source files to process
      */
-    public ListBuffer<File> filenames = null; // XXX sb protected
+    public Set<File> filenames = null; // XXX sb protected
 
     /** List of class files names passed on the command line
      */
@@ -202,7 +204,7 @@
      *  in `options' table and return all source filenames.
      *  @param flags    The array of command line arguments.
      */
-    public List<File> processArgs(String[] flags) { // XXX sb protected
+    public Collection<File> processArgs(String[] flags) { // XXX sb protected
         int ac = 0;
         while (ac < flags.length) {
             String flag = flags[ac];
@@ -294,7 +296,7 @@
             showClass(showClass);
         }
 
-        return filenames.toList();
+        return filenames;
     }
     // where
         private boolean checkDirectory(OptionName optName) {
@@ -342,7 +344,7 @@
         if (options == null)
             options = Options.instance(context); // creates a new one
 
-        filenames = new ListBuffer<File>();
+        filenames = new LinkedHashSet<File>();
         classnames = new ListBuffer<String>();
         JavaCompiler comp = null;
         /*
@@ -356,7 +358,7 @@
                 return EXIT_CMDERR;
             }
 
-            List<File> files;
+            Collection<File> files;
             try {
                 files = processArgs(CommandLine.parse(args));
                 if (files == null) {
--- a/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/nio/PathFileObject.java	Sun Feb 26 16:05:18 2012 -0800
@@ -205,6 +205,7 @@
 
     @Override
     public OutputStream openOutputStream() throws IOException {
+        fileManager.flushCache(this);
         ensureParentDirectoriesExist();
         return Files.newOutputStream(path);
     }
@@ -241,6 +242,7 @@
 
     @Override
     public Writer openWriter() throws IOException {
+        fileManager.flushCache(this);
         ensureParentDirectoriesExist();
         return new OutputStreamWriter(Files.newOutputStream(path), fileManager.getEncodingName());
     }
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Sun Feb 26 16:05:18 2012 -0800
@@ -27,15 +27,15 @@
 
 import java.util.*;
 
+import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.tree.*;
-import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.List;
+
 import static com.sun.tools.javac.util.ListBuffer.lb;
-
-import com.sun.tools.javac.tree.JCTree.*;
-
 import static com.sun.tools.javac.parser.Token.*;
 
 /** The parser maps a token sequence into an abstract syntax
@@ -57,7 +57,7 @@
 
     /** The scanner used for lexical analysis.
      */
-    private Lexer S;
+    protected Lexer S;
 
     /** The factory to be used for abstract syntax tree construction.
      */
@@ -99,9 +99,9 @@
         this.allowTWR = source.allowTryWithResources();
         this.allowDiamond = source.allowDiamond();
         this.allowMulticatch = source.allowMulticatch();
+        this.allowStringFolding = fac.options.getBoolean("allowStringFolding", true);
         this.keepDocComments = keepDocComments;
-        if (keepDocComments)
-            docComments = new HashMap<JCTree,String>();
+        docComments = keepDocComments ? new HashMap<JCTree,String>() : null;
         this.keepLineMap = keepLineMap;
         this.errorTree = F.Erroneous();
     }
@@ -146,6 +146,10 @@
      */
     boolean allowTWR;
 
+    /** Switch: should we fold strings?
+     */
+    boolean allowStringFolding;
+
     /** Switch: should we keep docComments?
      */
     boolean keepDocComments;
@@ -250,26 +254,44 @@
     }
 
     private JCErroneous syntaxError(int pos, String key, Token... args) {
-        return syntaxError(pos, null, key, args);
+        return syntaxError(pos, List.<JCTree>nil(), key, args);
     }
 
     private JCErroneous syntaxError(int pos, List<JCTree> errs, String key, Token... args) {
         setErrorEndPos(pos);
-        reportSyntaxError(pos, key, (Object[])args);
-        return toP(F.at(pos).Erroneous(errs));
+        JCErroneous err = F.at(pos).Erroneous(errs);
+        reportSyntaxError(err, key, (Object[])args);
+        if (errs != null) {
+            JCTree last = errs.last();
+            if (last != null)
+                storeEnd(last, pos);
+        }
+        return toP(err);
     }
 
     private int errorPos = Position.NOPOS;
+
     /**
-     * Report a syntax error at given position using the given
-     * argument unless one was already reported at the same position.
+     * Report a syntax using the given the position parameter and arguments,
+     * unless one was already reported at the same position.
      */
     private void reportSyntaxError(int pos, String key, Object... args) {
+        JCDiagnostic.DiagnosticPosition diag = new JCDiagnostic.SimpleDiagnosticPosition(pos);
+        reportSyntaxError(diag, key, args);
+    }
+
+    /**
+     * Report a syntax error using the given DiagnosticPosition object and
+     * arguments, unless one was already reported at the same position.
+     */
+    private void reportSyntaxError(JCDiagnostic.DiagnosticPosition diagPos, String key, Object... args) {
+        int pos = diagPos.getPreferredPosition();
         if (pos > S.errPos() || pos == Position.NOPOS) {
-            if (S.token() == EOF)
-                error(pos, "premature.eof");
-            else
-                error(pos, key, args);
+            if (S.token() == EOF) {
+                error(diagPos, "premature.eof");
+            } else {
+                error(diagPos, key, args);
+            }
         }
         S.errPos(pos);
         if (S.pos() == errorPos)
@@ -307,7 +329,7 @@
     /** Report an illegal start of expression/type error at given position.
      */
     JCExpression illegal(int pos) {
-        setErrorEndPos(S.pos());
+        setErrorEndPos(pos);
         if ((mode & EXPR) != 0)
             return syntaxError(pos, "illegal.start.of.expr");
         else
@@ -336,7 +358,7 @@
      *  indexed by the tree nodes they refer to.
      *  defined only if option flag keepDocComment is set.
      */
-    Map<JCTree, String> docComments;
+    private final Map<JCTree, String> docComments;
 
     /** Make an entry into docComments hashtable,
      *  provided flag keepDocComments is set and given doc comment is non-null.
@@ -458,6 +480,10 @@
         return t;
     }
 
+    JCExpression literal(Name prefix) {
+        return literal(prefix, S.pos());
+    }
+
     /**
      * Literal =
      *     INTLITERAL
@@ -470,8 +496,7 @@
      *   | FALSE
      *   | NULL
      */
-    JCExpression literal(Name prefix) {
-        int pos = S.pos();
+    JCExpression literal(Name prefix, int pos) {
         JCExpression t = errorTree;
         switch (S.token()) {
         case INTLITERAL:
@@ -757,6 +782,8 @@
          *  by a single literal representing the concatenated string.
          */
         protected StringBuffer foldStrings(JCTree tree) {
+            if (!allowStringFolding)
+                return null;
             List<String> buf = List.nil();
             while (true) {
                 if (tree.getTag() == JCTree.LITERAL) {
@@ -863,7 +890,7 @@
                     (S.token() == INTLITERAL || S.token() == LONGLITERAL) &&
                     S.radix() == 10) {
                     mode = EXPR;
-                    t = literal(names.hyphen);
+                    t = literal(names.hyphen, pos);
                 } else {
                     t = term3();
                     return F.at(pos).Unary(unoptag(token), t);
@@ -1261,15 +1288,17 @@
                 case GTGT:
                     S.token(GT);
                     break;
+                case GT:
+                    S.nextToken();
+                    break;
                 default:
-                    accept(GT);
+                    args.append(syntaxError(S.pos(), "expected", GT));
                     break;
                 }
                 return args.toList();
             }
         } else {
-            syntaxError(S.pos(), "expected", LT);
-            return List.nil();
+            return List.<JCExpression>of(syntaxError(S.pos(), "expected", LT));
         }
     }
 
@@ -1294,12 +1323,12 @@
             return F.at(pos).Wildcard(t, bound);
         } else if (S.token() == IDENTIFIER) {
             //error recovery
-            reportSyntaxError(S.prevEndPos(), "expected3",
-                    GT, EXTENDS, SUPER);
             TypeBoundKind t = F.at(Position.NOPOS).TypeBoundKind(BoundKind.UNBOUND);
             JCExpression wc = toP(F.at(pos).Wildcard(t, null));
             JCIdent id = toP(F.at(S.pos()).Ident(ident()));
-            return F.at(pos).Erroneous(List.<JCTree>of(wc, id));
+            JCErroneous err = F.at(pos).Erroneous(List.<JCTree>of(wc, id));
+            reportSyntaxError(err, "expected3", GT, EXTENDS, SUPER);
+            return err;
         } else {
             TypeBoundKind t = toP(F.at(pos).TypeBoundKind(BoundKind.UNBOUND));
             return toP(F.at(pos).Wildcard(t, null));
@@ -1375,20 +1404,23 @@
         int oldmode = mode;
         mode = TYPE;
         boolean diamondFound = false;
+        int lastTypeargsPos = -1;
         if (S.token() == LT) {
             checkGenerics();
+            lastTypeargsPos = S.pos();
             t = typeArguments(t, true);
             diamondFound = (mode & DIAMOND) != 0;
         }
         while (S.token() == DOT) {
             if (diamondFound) {
                 //cannot select after a diamond
-                illegal(S.pos());
+                illegal();
             }
             int pos = S.pos();
             S.nextToken();
             t = toP(F.at(pos).Select(t, ident()));
             if (S.token() == LT) {
+                lastTypeargsPos = S.pos();
                 checkGenerics();
                 t = typeArguments(t, true);
                 diamondFound = (mode & DIAMOND) != 0;
@@ -1397,7 +1429,11 @@
         mode = oldmode;
         if (S.token() == LBRACKET) {
             JCExpression e = arrayCreatorRest(newpos, t);
-            if (typeArgs != null) {
+            if (diamondFound) {
+                reportSyntaxError(lastTypeargsPos, "cannot.create.array.with.diamond");
+                return toP(F.at(newpos).Erroneous(List.of(e)));
+            }
+            else if (typeArgs != null) {
                 int pos = newpos;
                 if (!typeArgs.isEmpty() && typeArgs.head.pos != Position.NOPOS) {
                     // note: this should always happen but we should
@@ -1406,15 +1442,16 @@
                     pos = typeArgs.head.pos;
                 }
                 setErrorEndPos(S.prevEndPos());
-                reportSyntaxError(pos, "cannot.create.array.with.type.arguments");
-                return toP(F.at(newpos).Erroneous(typeArgs.prepend(e)));
+                JCErroneous err = F.at(pos).Erroneous(typeArgs.prepend(e));
+                reportSyntaxError(err, "cannot.create.array.with.type.arguments");
+                return toP(err);
             }
             return e;
         } else if (S.token() == LPAREN) {
             return classCreatorRest(newpos, null, typeArgs, t);
         } else {
-            reportSyntaxError(S.pos(), "expected2",
-                               LPAREN, LBRACKET);
+            setErrorEndPos(S.pos());
+            reportSyntaxError(S.pos(), "expected2", LPAREN, LBRACKET);
             t = toP(F.at(newpos).NewClass(null, typeArgs, t, List.<JCExpression>nil(), null));
             return toP(F.at(newpos).Erroneous(List.<JCTree>of(t)));
         }
@@ -1444,7 +1481,8 @@
             if (S.token() == LBRACE) {
                 return arrayInitializer(newpos, elemtype);
             } else {
-                return syntaxError(S.pos(), "array.dimension.missing");
+                JCExpression t = toP(F.at(newpos).NewArray(elemtype, List.<JCExpression>nil(), null));
+                return syntaxError(S.pos(), List.<JCTree>of(t), "array.dimension.missing");
             }
         } else {
             ListBuffer<JCExpression> dims = new ListBuffer<JCExpression>();
@@ -1830,7 +1868,7 @@
 
     /** CatchClause     = CATCH "(" FormalParameter ")" Block
      */
-    JCCatch catchClause() {
+    protected JCCatch catchClause() {
         int pos = S.pos();
         accept(CATCH);
         accept(LPAREN);
@@ -1960,7 +1998,7 @@
     JCModifiers modifiersOpt() {
         return modifiersOpt(null);
     }
-    JCModifiers modifiersOpt(JCModifiers partial) {
+    protected JCModifiers modifiersOpt(JCModifiers partial) {
         long flags;
         ListBuffer<JCAnnotation> annotations = new ListBuffer<JCAnnotation>();
         int pos;
@@ -1993,6 +2031,7 @@
             case SYNCHRONIZED: flag = Flags.SYNCHRONIZED; break;
             case STRICTFP    : flag = Flags.STRICTFP; break;
             case MONKEYS_AT  : flag = Flags.ANNOTATION; break;
+            case ERROR       : flag = 0; S.nextToken(); break;
             default: break loop;
             }
             if ((flags & flag) != 0) error(S.pos(), "repeated.modifier");
@@ -2206,9 +2245,12 @@
 
     /** Resource = VariableModifiersOpt Type VariableDeclaratorId = Expression
      */
-    JCTree resource() {
-        return variableDeclaratorRest(S.pos(), optFinal(Flags.FINAL),
-                                      parseType(), ident(), true, null);
+    protected JCTree resource() {
+        JCModifiers optFinal = optFinal(Flags.FINAL);
+        JCExpression type = parseType();
+        int pos = S.pos();
+        Name ident = ident();
+        return variableDeclaratorRest(pos, optFinal, type, ident, true, null);
     }
 
     /** CompilationUnit = [ { "@" Annotation } PACKAGE Qualident ";"] {ImportDeclaration} {TypeDeclaration}
@@ -2555,7 +2597,7 @@
      *    | ModifiersOpt Type Ident
      *      ( ConstantDeclaratorsRest | InterfaceMethodDeclaratorRest ";" )
      */
-    List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface) {
+    protected List<JCTree> classOrInterfaceBodyDeclaration(Name className, boolean isInterface) {
         if (S.token() == SEMI) {
             S.nextToken();
             return List.<JCTree>nil();
@@ -2757,7 +2799,7 @@
     /** FormalParameter = { FINAL | '@' Annotation } Type VariableDeclaratorId
      *  LastFormalParameter = { FINAL | '@' Annotation } Type '...' Ident | FormalParameter
      */
-    JCVariableDecl formalParameter() {
+    protected JCVariableDecl formalParameter() {
         JCModifiers mods = optFinal(Flags.PARAMETER);
         JCExpression type = parseType();
         if (S.token() == ELLIPSIS) {
@@ -2775,6 +2817,10 @@
         log.error(DiagnosticFlag.SYNTAX, pos, key, args);
     }
 
+    void error(DiagnosticPosition pos, String key, Object ... args) {
+        log.error(DiagnosticFlag.SYNTAX, pos, key, args);
+    }
+
     void warning(int pos, String key, Object ... args) {
         log.warning(pos, key, args);
     }
@@ -2794,8 +2840,9 @@
         case JCTree.ERRONEOUS:
             return t;
         default:
-            error(t.pos, "not.stmt");
-            return F.at(t.pos).Erroneous(List.<JCTree>of(t));
+            JCExpression ret = F.at(t.pos).Erroneous(List.<JCTree>of(t));
+            error(ret, "not.stmt");
+            return ret;
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/parser/Scanner.java	Sun Feb 26 16:05:18 2012 -0800
@@ -982,8 +982,16 @@
     }
 
     /** Sets the current token.
+     * This method is primarily used to update the token stream when the
+     * parser is handling the end of nested type arguments such as
+     * {@code List<List<String>>} and needs to disambiguate between
+     * repeated use of ">" and relation operators such as ">>" and ">>>". Noting
+     * that this does not handle arbitrary tokens containing Unicode escape
+     * sequences.
      */
     public void token(Token token) {
+        pos += this.token.name.length() - token.name.length();
+        prevEndPos = pos;
         this.token = token;
     }
 
--- a/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/processing/JavacFiler.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -455,9 +455,24 @@
         // TODO: Only support reading resources in selected output
         // locations?  Only allow reading of non-source, non-class
         // files from the supported input locations?
-        FileObject fileObject = fileManager.getFileForInput(location,
+
+        // In the following, getFileForInput is the "obvious" method
+        // to use, but it does not have the "obvious" semantics for
+        // SOURCE_OUTPUT and CLASS_OUTPUT. Conversely, getFileForOutput
+        // does not have the correct semantics for any "path" location
+        // with more than one component. So, for now, we use a hybrid
+        // invocation.
+        FileObject fileObject;
+        if (location.isOutputLocation()) {
+            fileObject = fileManager.getFileForOutput(location,
+                    pkg.toString(),
+                    relativeName.toString(),
+                    null);
+        } else {
+            fileObject = fileManager.getFileForInput(location,
                     pkg.toString(),
                     relativeName.toString());
+        }
         if (fileObject == null) {
             String name = (pkg.length() == 0)
                     ? relativeName.toString() : (pkg + "/" + relativeName);
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Sun Feb 26 16:05:18 2012 -0800
@@ -462,6 +462,9 @@
 compiler.err.cannot.create.array.with.type.arguments=\
     cannot create array with type arguments
 
+compiler.err.cannot.create.array.with.diamond=\
+    cannot create array with ''<>''
+
 #
 # limits.  We don't give the limits in the diagnostic because we expect
 # them to change, yet we want to use the same diagnostic.  These are all
--- a/src/share/classes/com/sun/tools/javac/util/AbstractLog.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/util/AbstractLog.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,6 +96,19 @@
 
     /** Report an error, unless another error was already reported at same
      *  source position.
+     *  @param flag   A flag to set on the diagnostic
+     *  @param pos    The source position at which to report the error.
+     *  @param key    The key for the localized error message.
+     *  @param args   Fields of the error message.
+     */
+    public void error(DiagnosticFlag flag, DiagnosticPosition pos, String key, Object ... args) {
+        JCDiagnostic d = diags.error(source, pos, key, args);
+        d.setFlag(flag);
+        report(d);
+    }
+
+    /** Report an error, unless another error was already reported at same
+     *  source position.
      *  @param pos    The source position at which to report the error.
      *  @param key    The key for the localized error message.
      *  @param args   Fields of the error message.
--- a/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javac/util/BaseFileManager.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2010, 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
@@ -322,16 +322,46 @@
 
     // <editor-fold defaultstate="collapsed" desc="Content cache">
     public CharBuffer getCachedContent(JavaFileObject file) {
-        SoftReference<CharBuffer> r = contentCache.get(file);
-        return (r == null ? null : r.get());
+        ContentCacheEntry e = contentCache.get(file);
+        if (e == null)
+            return null;
+
+        if (!e.isValid(file)) {
+            contentCache.remove(file);
+            return null;
+        }
+
+        return e.getValue();
     }
 
     public void cache(JavaFileObject file, CharBuffer cb) {
-        contentCache.put(file, new SoftReference<CharBuffer>(cb));
+        contentCache.put(file, new ContentCacheEntry(file, cb));
     }
 
-    protected final Map<JavaFileObject, SoftReference<CharBuffer>> contentCache
-            = new HashMap<JavaFileObject, SoftReference<CharBuffer>>();
+    public void flushCache(JavaFileObject file) {
+        contentCache.remove(file);
+    }
+
+    protected final Map<JavaFileObject, ContentCacheEntry> contentCache
+            = new HashMap<JavaFileObject, ContentCacheEntry>();
+
+    protected static class ContentCacheEntry {
+        final long timestamp;
+        final SoftReference<CharBuffer> ref;
+
+        ContentCacheEntry(JavaFileObject file, CharBuffer cb) {
+            this.timestamp = file.getLastModified();
+            this.ref = new SoftReference<CharBuffer>(cb);
+        }
+
+        boolean isValid(JavaFileObject file) {
+            return timestamp == file.getLastModified();
+        }
+
+        CharBuffer getValue() {
+            return ref.get();
+        }
+    }
     // </editor-fold>
 
     public static Kind getKind(String name) {
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,11 +46,11 @@
 public class AnnotationTypeDocImpl
         extends ClassDocImpl implements AnnotationTypeDoc {
 
-    AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
+    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
         this(env, sym, null, null, null);
     }
 
-    AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym,
+    public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym,
                           String doc, JCClassDecl tree, Position.LineMap lineMap) {
         super(env, sym, doc, tree, lineMap);
     }
--- a/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/AnnotationTypeElementDocImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,11 +45,11 @@
 public class AnnotationTypeElementDocImpl
         extends MethodDocImpl implements AnnotationTypeElementDoc {
 
-    AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym) {
+    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym) {
         super(env, sym);
     }
 
-    AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym,
+    public AnnotationTypeElementDocImpl(DocEnv env, MethodSymbol sym,
                                  String doc, JCMethodDecl tree, Position.LineMap lineMap) {
         super(env, sym, doc, tree, lineMap);
     }
--- a/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -744,17 +744,16 @@
         // search inner classes
         //### Add private entry point to avoid creating array?
         //### Replicate code in innerClasses here to avoid consing?
-        ClassDoc innerClasses[] = innerClasses();
-        for (int i = 0; i < innerClasses.length; i++) {
-            if (innerClasses[i].name().equals(className) ||
-                //### This is from original javadoc but it looks suspicious to me...
-                //### I believe it is attempting to compensate for the confused
-                //### convention of including the nested class qualifiers in the
-                //### 'name' of the inner class, rather than the true simple name.
-                innerClasses[i].name().endsWith(className)) {
-                return innerClasses[i];
+        for (ClassDoc icd : innerClasses()) {
+            if (icd.name().equals(className) ||
+                    //### This is from original javadoc but it looks suspicious to me...
+                    //### I believe it is attempting to compensate for the confused
+                    //### convention of including the nested class qualifiers in the
+                    //### 'name' of the inner class, rather than the true simple name.
+                    icd.name().endsWith("." + className)) {
+                return icd;
             } else {
-                ClassDoc innercd = ((ClassDocImpl) innerClasses[i]).searchClass(className);
+                ClassDoc innercd = ((ClassDocImpl) icd).searchClass(className);
                 if (innercd != null) {
                     return innercd;
                 }
--- a/src/share/classes/com/sun/tools/javadoc/Comment.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/Comment.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,10 +25,7 @@
 
 package com.sun.tools.javadoc;
 
-import java.util.Locale;
-
 import com.sun.javadoc.*;
-
 import com.sun.tools.javac.util.ListBuffer;
 
 /**
@@ -115,7 +112,7 @@
                                 state = TAG_NAME;
                             }
                             break;
-                    };
+                    }
                     if (ch == '\n') {
                         newLine = true;
                     } else if (!isWhite) {
@@ -134,7 +131,7 @@
                     case IN_TEXT:
                         parseCommentComponent(tagName, textStart, lastNonWhite+1);
                         break;
-                };
+                }
             }
 
             /**
@@ -396,16 +393,15 @@
      * else
      *    return -1.
      */
-    private static int inlineTagFound(DocImpl holder,  String inlinetext, int start) {
+    private static int inlineTagFound(DocImpl holder, String inlinetext, int start) {
         DocEnv docenv = holder.env;
-        int linkstart;
-        if (start == inlinetext.length() ||
-              (linkstart = inlinetext.indexOf("{@", start)) == -1) {
+        int linkstart = inlinetext.indexOf("{@", start);
+        if (start == inlinetext.length() || linkstart == -1) {
             return -1;
-        } else if(inlinetext.indexOf('}', start) == -1) {
+        } else if (inlinetext.indexOf('}', linkstart) == -1) {
             //Missing '}'.
             docenv.warning(holder, "tag.Improper_Use_Of_Link_Tag",
-                          inlinetext.substring(linkstart, inlinetext.length()));
+                    inlinetext.substring(linkstart, inlinetext.length()));
             return -1;
         } else {
             return linkstart;
@@ -425,6 +421,7 @@
     /**
      * Return text for this Doc comment.
      */
+    @Override
     public String toString() {
         return text;
     }
--- a/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/DocEnv.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -84,7 +84,7 @@
     final Symbol externalizableSym;
 
     /** Access filter (public, protected, ...).  */
-    ModifierFilter showAccess;
+    protected ModifierFilter showAccess;
 
     /** True if we are using a sentence BreakIterator. */
     boolean breakiterator;
@@ -102,7 +102,7 @@
     boolean docClasses = false;
 
     /** Does the doclet only expect pre-1.5 doclet API? */
-    boolean legacyDoclet = true;
+    protected boolean legacyDoclet = true;
 
     /**
      * Set this to true if you would like to not emit any errors, warnings and
@@ -115,7 +115,7 @@
      *
      * @param context      Context for this javadoc instance.
      */
-    private DocEnv(Context context) {
+    protected DocEnv(Context context) {
         context.put(docEnvKey, this);
 
         messager = Messager.instance0(context);
@@ -517,7 +517,7 @@
         messager.exit();
     }
 
-    private Map<PackageSymbol, PackageDocImpl> packageMap =
+    protected Map<PackageSymbol, PackageDocImpl> packageMap =
             new HashMap<PackageSymbol, PackageDocImpl>();
     /**
      * Return the PackageDoc of this package symbol.
@@ -545,12 +545,12 @@
     }
 
 
-    private Map<ClassSymbol, ClassDocImpl> classMap =
+    protected Map<ClassSymbol, ClassDocImpl> classMap =
             new HashMap<ClassSymbol, ClassDocImpl>();
     /**
      * Return the ClassDoc (or a subtype) of this class symbol.
      */
-    ClassDocImpl getClassDoc(ClassSymbol clazz) {
+    public ClassDocImpl getClassDoc(ClassSymbol clazz) {
         ClassDocImpl result = classMap.get(clazz);
         if (result != null) return result;
         if (isAnnotationType(clazz)) {
@@ -565,7 +565,7 @@
     /**
      * Create the ClassDoc (or a subtype) for a class symbol.
      */
-    void makeClassDoc(ClassSymbol clazz, String docComment, JCClassDecl tree, Position.LineMap lineMap) {
+    protected void makeClassDoc(ClassSymbol clazz, String docComment, JCClassDecl tree, Position.LineMap lineMap) {
         ClassDocImpl result = classMap.get(clazz);
         if (result != null) {
             if (docComment != null) result.setRawCommentText(docComment);
@@ -580,20 +580,20 @@
         classMap.put(clazz, result);
     }
 
-    private static boolean isAnnotationType(ClassSymbol clazz) {
+    protected static boolean isAnnotationType(ClassSymbol clazz) {
         return ClassDocImpl.isAnnotationType(clazz);
     }
 
-    private static boolean isAnnotationType(JCClassDecl tree) {
+    protected static boolean isAnnotationType(JCClassDecl tree) {
         return (tree.mods.flags & Flags.ANNOTATION) != 0;
     }
 
-    private Map<VarSymbol, FieldDocImpl> fieldMap =
+    protected Map<VarSymbol, FieldDocImpl> fieldMap =
             new HashMap<VarSymbol, FieldDocImpl>();
     /**
      * Return the FieldDoc of this var symbol.
      */
-    FieldDocImpl getFieldDoc(VarSymbol var) {
+    public FieldDocImpl getFieldDoc(VarSymbol var) {
         FieldDocImpl result = fieldMap.get(var);
         if (result != null) return result;
         result = new FieldDocImpl(this, var);
@@ -603,7 +603,7 @@
     /**
      * Create a FieldDoc for a var symbol.
      */
-    void makeFieldDoc(VarSymbol var, String docComment, JCVariableDecl tree, Position.LineMap lineMap) {
+    protected void makeFieldDoc(VarSymbol var, String docComment, JCVariableDecl tree, Position.LineMap lineMap) {
         FieldDocImpl result = fieldMap.get(var);
         if (result != null) {
             if (docComment != null) result.setRawCommentText(docComment);
@@ -614,13 +614,13 @@
         }
     }
 
-    private Map<MethodSymbol, ExecutableMemberDocImpl> methodMap =
+    protected Map<MethodSymbol, ExecutableMemberDocImpl> methodMap =
             new HashMap<MethodSymbol, ExecutableMemberDocImpl>();
     /**
      * Create a MethodDoc for this MethodSymbol.
      * Should be called only on symbols representing methods.
      */
-    void makeMethodDoc(MethodSymbol meth, String docComment,
+    protected void makeMethodDoc(MethodSymbol meth, String docComment,
                        JCMethodDecl tree, Position.LineMap lineMap) {
         MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
         if (result != null) {
@@ -649,7 +649,7 @@
      * Create the ConstructorDoc for a MethodSymbol.
      * Should be called only on symbols representing constructors.
      */
-    void makeConstructorDoc(MethodSymbol meth, String docComment,
+    protected void makeConstructorDoc(MethodSymbol meth, String docComment,
                             JCMethodDecl tree, Position.LineMap lineMap) {
         ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
         if (result != null) {
@@ -678,7 +678,7 @@
      * Create the AnnotationTypeElementDoc for a MethodSymbol.
      * Should be called only on symbols representing annotation type elements.
      */
-    void makeAnnotationTypeElementDoc(MethodSymbol meth,
+    protected void makeAnnotationTypeElementDoc(MethodSymbol meth,
                                       String docComment, JCMethodDecl tree, Position.LineMap lineMap) {
         AnnotationTypeElementDocImpl result =
             (AnnotationTypeElementDocImpl)methodMap.get(meth);
--- a/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/DocImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -92,7 +92,7 @@
      * So subclasses have the option to do lazy initialization of
      * "documentation" string.
      */
-    String documentation() {
+    protected String documentation() {
         if (documentation == null) documentation = "";
         return documentation;
     }
--- a/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocClassReader.java	Sun Feb 26 16:05:18 2012 -0800
@@ -35,7 +35,7 @@
 /** Javadoc uses an extended class reader that records package.html entries
  *  @author Neal Gafter
  */
-class JavadocClassReader extends ClassReader {
+public class JavadocClassReader extends ClassReader {
 
     public static JavadocClassReader instance0(Context context) {
         ClassReader instance = context.get(classReaderKey);
@@ -59,7 +59,7 @@
     private EnumSet<JavaFileObject.Kind> noSource = EnumSet.of(JavaFileObject.Kind.CLASS,
                                                                JavaFileObject.Kind.HTML);
 
-    private JavadocClassReader(Context context) {
+    public JavadocClassReader(Context context) {
         super(context, true);
         docenv = DocEnv.instance(context);
         preferSource = true;
--- a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Sun Feb 26 16:05:18 2012 -0800
@@ -31,7 +31,6 @@
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.Enter;
-import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.*;
 import javax.tools.JavaFileObject;
 
@@ -65,6 +64,7 @@
     final Messager messager;
     final DocEnv docenv;
 
+    @Override
     public void main(List<JCCompilationUnit> trees) {
         // count all Enter errors as warnings.
         int nerrors = messager.nerrors;
@@ -73,6 +73,7 @@
         messager.nerrors = nerrors;
     }
 
+    @Override
     public void visitTopLevel(JCCompilationUnit tree) {
         super.visitTopLevel(tree);
         if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
@@ -81,10 +82,11 @@
         }
     }
 
+    @Override
     public void visitClassDef(JCClassDecl tree) {
         super.visitClassDef(tree);
-        if (tree.sym != null && tree.sym.kind == Kinds.TYP) {
-            if (tree.sym == null) return;
+        if (tree.sym == null) return;
+        if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) {
             String comment = env.toplevel.docComments.get(tree);
             ClassSymbol c = tree.sym;
             docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
@@ -92,6 +94,7 @@
     }
 
     /** Don't complain about a duplicate class. */
+    @Override
     protected void duplicateClass(DiagnosticPosition pos, ClassSymbol c) {}
 
 }
--- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Sun Feb 26 16:05:18 2012 -0800
@@ -38,7 +38,7 @@
  *  done by javac.
  *  @author Neal Gafter
  */
-class JavadocMemberEnter extends MemberEnter {
+public class JavadocMemberEnter extends MemberEnter {
     public static JavadocMemberEnter instance0(Context context) {
         MemberEnter instance = context.get(memberEnterKey);
         if (instance == null)
--- a/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/PackageDocImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,7 +96,7 @@
     /**
      * Do lazy initialization of "documentation" string.
      */
-    String documentation() {
+    protected String documentation() {
         if (documentation != null)
             return documentation;
         if (docPath != null) {
--- a/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/ParamTagImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2003, 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
@@ -44,6 +44,11 @@
     private final String parameterComment;
     private final boolean isTypeParameter;
 
+    /**
+     * Cached inline tags.
+     */
+    private Tag[] inlineTags;
+
     ParamTagImpl(DocImpl holder, String name, String text) {
         super(holder, name, text);
         String[] sa = divideAtWhite();
@@ -71,6 +76,7 @@
     /**
      * Return the kind of this tag.
      */
+    @Override
     public String kind() {
         return "@param";
     }
@@ -85,6 +91,7 @@
     /**
      * convert this object to a string.
      */
+    @Override
     public String toString() {
         return name + ":" + text;
     }
@@ -97,7 +104,11 @@
      * @see TagImpl#inlineTagImpls()
      * @see ThrowsTagImpl#inlineTagImpls()
      */
+    @Override
     public Tag[] inlineTags() {
-        return Comment.getInlineTags(holder, parameterComment);
+        if (inlineTags == null) {
+            inlineTags = Comment.getInlineTags(holder, parameterComment);
+        }
+        return inlineTags;
     }
 }
--- a/src/share/classes/com/sun/tools/javadoc/SerialFieldTagImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/SerialFieldTagImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2006, 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
@@ -80,6 +80,9 @@
      */
     private void parseSerialFieldString() {
         int len = text.length();
+        if (len == 0) {
+            return;
+        }
 
         // if no white space found
         /* Skip white space. */
--- a/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/com/sun/tools/javadoc/ThrowsTagImpl.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2003, 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
@@ -43,6 +43,11 @@
     private final String exceptionName;
     private final String exceptionComment;
 
+    /**
+     * Cached inline tags.
+     */
+    private Tag[] inlineTags;
+
     ThrowsTagImpl(DocImpl holder, String name, String text) {
         super(holder, name, text);
         String[] sa = divideAtWhite();
@@ -93,6 +98,7 @@
      * Return the kind of this tag.  Always "@throws" for instances
      * of ThrowsTagImpl.
      */
+    @Override
     public String kind() {
         return "@throws";
     }
@@ -105,7 +111,11 @@
      * @see TagImpl#inlineTagImpls()
      * @see ParamTagImpl#inlineTagImpls()
      */
+    @Override
     public Tag[] inlineTags() {
-        return Comment.getInlineTags(holder, exceptionComment());
+        if (inlineTags == null) {
+            inlineTags = Comment.getInlineTags(holder, exceptionComment());
+        }
+        return inlineTags;
     }
 }
--- a/src/share/classes/javax/tools/JavaCompiler.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/src/share/classes/javax/tools/JavaCompiler.java	Sun Feb 26 16:05:18 2012 -0800
@@ -26,10 +26,8 @@
 package javax.tools;
 
 import java.io.File;
-import java.io.InputStream;
 import java.io.Writer;
 import java.nio.charset.Charset;
-import java.util.List;
 import java.util.Locale;
 import java.util.concurrent.Callable;
 import javax.annotation.processing.Processor;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/T6735320/SerialFieldTest.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+import java.io.ObjectStreamField;
+import java.io.Serializable;
+
+public class SerialFieldTest implements Serializable {
+    /**
+     * @serialField
+     */
+    private static final ObjectStreamField[] serialPersistentFields = {
+        new ObjectStreamField("i", int.class),
+    };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/com/sun/javadoc/T6735320/T6735320.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,57 @@
+/*
+ * 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 6735320
+ * @summary javadoc throws exception if serialField value is missing
+ * @library  ../lib/
+ * @build    JavadocTester T6735320
+ * @run main T6735320
+ */
+public class T6735320 extends JavadocTester {
+
+    private static final String BUG_ID = "6735320";
+    private static final String[] ARGS = new String[]{
+        "-d", BUG_ID + ".out",
+        SRC_DIR + FS + "SerialFieldTest.java"
+    };
+
+    public String getBugId() {
+        return BUG_ID;
+    }
+
+    public String getBugName() {
+        return getClass().getName();
+    }
+
+    public static void main(String... args) {
+        T6735320 tester = new T6735320();
+        if (tester.runJavadoc(ARGS) != 0) {
+            throw new AssertionError("non-zero return code from javadoc");
+        }
+        if (tester.getErrorOutput().contains("StringIndexOutOfBoundsException")) {
+            throw new AssertionError("javadoc threw StringIndexOutOfBoundsException");
+        }
+    }
+}
--- a/test/com/sun/javadoc/lib/JavadocTester.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/com/sun/javadoc/lib/JavadocTester.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2009, 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
@@ -197,8 +197,13 @@
         initOutputBuffers();
 
         ByteArrayOutputStream stdout = new ByteArrayOutputStream();
-        PrintStream prev = System.out;
+        PrintStream prevOut = System.out;
         System.setOut(new PrintStream(stdout));
+
+        ByteArrayOutputStream stderr = new ByteArrayOutputStream();
+        PrintStream prevErr = System.err;
+        System.setErr(new PrintStream(stderr));
+
         int returnCode = com.sun.tools.javadoc.Main.execute(
                 getBugName(),
                 new PrintWriter(errors, true),
@@ -207,8 +212,11 @@
                 docletClass,
                 getClass().getClassLoader(),
                 args);
-        System.setOut(prev);
+        System.setOut(prevOut);
         standardOut = new StringBuffer(stdout.toString());
+        System.setErr(prevErr);
+        errors.write(NL + stderr.toString());
+
         printJavadocOutput();
         return returnCode;
     }
--- a/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/com/sun/javadoc/testLinkTaglet/TestLinkTaglet.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
 
 /*
  * @test
- * @bug      4732864 6280605
+ * @bug      4732864 6280605 7064544
  * @summary  Make sure that you can link from one member to another using
- *           non-qualified name.
+ *           non-qualified name, furthermore, ensure the right one is linked.
  * @author   jamieh
  * @library  ../lib/
  * @build    JavadocTester
@@ -36,7 +36,7 @@
 public class TestLinkTaglet extends JavadocTester {
 
     //Test information.
-    private static final String BUG_ID = "4732864-6280605";
+    private static final String BUG_ID = "4732864-6280605-7064544";
 
     //Javadoc arguments.
     private static final String[] ARGS = new String[] {
--- a/test/com/sun/javadoc/testLinkTaglet/pkg/C.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/com/sun/javadoc/testLinkTaglet/pkg/C.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 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
@@ -34,6 +34,11 @@
 public class C {
 
     public InnerC MEMBER = new InnerC();
+    /**
+     *  A red herring inner class to confuse the matching, thus to
+     *  ensure the right one is linked.
+     */
+    public class RedHerringInnerC {}
 
     /**
      * Link to member in outer class: {@link #MEMBER} <br/>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/7102515/T7102515.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,11 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7102515
+ * @summary javac running very very long and not returning
+ * @compile/fail/ref=T7102515.out -XDrawDiagnostics T7102515.java
+ */
+
+class T7102515 {
+    T7102515 badBinary = new T7102515() + new T7102515();
+    Object badUnary = badBinary++;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/7102515/T7102515.out	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,3 @@
+T7102515.java:9:41: compiler.err.operator.cant.be.applied.1: +, T7102515, T7102515
+T7102515.java:10:32: compiler.err.operator.cant.be.applied: ++, T7102515, null
+2 errors
--- a/test/tools/javac/StringsInSwitch/StringSwitches.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/StringsInSwitch/StringSwitches.java	Sun Feb 26 16:05:18 2012 -0800
@@ -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
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 6827009
+ * @bug 6827009 7071246
  * @summary Positive tests for strings in switch.
  * @author  Joseph D. Darcy
  */
@@ -36,6 +36,7 @@
         failures += testPileup();
         failures += testSwitchingTwoWays();
         failures += testNamedBreak();
+        failures += testExtraParens();
 
         if (failures > 0) {
             throw new RuntimeException();
@@ -260,4 +261,19 @@
         result |= (1<<5);
         return result;
     }
+
+    private static int testExtraParens() {
+        int failures = 1;
+        String s = "first";
+
+        switch(s) {
+        case (("first")):
+            failures = 0;
+            break;
+        case ("second"):
+            throw new RuntimeException("Should not be reached.");
+        }
+
+        return failures;
+    }
 }
--- a/test/tools/javac/T6358166.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/T6358166.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,7 @@
 
         Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
         compilerMain.setOptions(Options.instance(context));
-        compilerMain.filenames = new ListBuffer<File>();
+        compilerMain.filenames = new LinkedHashSet<File>();
         compilerMain.processArgs(args);
 
         JavaCompiler c = JavaCompiler.instance(context);
--- a/test/tools/javac/T6358168.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/T6358168.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -72,7 +72,7 @@
 
         Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
         compilerMain.setOptions(Options.instance(context));
-        compilerMain.filenames = new ListBuffer<File>();
+        compilerMain.filenames = new LinkedHashSet<File>();
         compilerMain.processArgs(new String[] { "-d", "." });
 
         JavaCompiler compiler = JavaCompiler.instance(context);
@@ -91,7 +91,7 @@
 
         Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
         compilerMain.setOptions(Options.instance(context));
-        compilerMain.filenames = new ListBuffer<File>();
+        compilerMain.filenames = new LinkedHashSet<File>();
         compilerMain.processArgs(new String[] {
                                      "-XprintRounds",
                                      "-processorpath", testClasses,
--- a/test/tools/javac/TryWithResources/BadTwr.out	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/TryWithResources/BadTwr.out	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
-BadTwr.java:13:39: compiler.err.already.defined: r1, main(java.lang.String...)
-BadTwr.java:18:13: compiler.err.already.defined: args, main(java.lang.String...)
+BadTwr.java:13:46: compiler.err.already.defined: r1, main(java.lang.String...)
+BadTwr.java:18:20: compiler.err.already.defined: args, main(java.lang.String...)
 BadTwr.java:21:13: compiler.err.cant.assign.val.to.final.var: thatsIt
-BadTwr.java:26:17: compiler.err.already.defined: name, main(java.lang.String...)
+BadTwr.java:26:24: compiler.err.already.defined: name, main(java.lang.String...)
 4 errors
--- a/test/tools/javac/TryWithResources/DuplicateResourceDecl.out	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/TryWithResources/DuplicateResourceDecl.out	Sun Feb 26 16:05:18 2012 -0800
@@ -1,2 +1,2 @@
-DuplicateResourceDecl.java:12:45: compiler.err.already.defined: c, main(java.lang.String[])
+DuplicateResourceDecl.java:12:56: compiler.err.already.defined: c, main(java.lang.String[])
 1 error
--- a/test/tools/javac/TryWithResources/ResourceInterface.out	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/TryWithResources/ResourceInterface.out	Sun Feb 26 16:05:18 2012 -0800
@@ -1,2 +1,2 @@
-ResourceInterface.java:38:13: compiler.err.unreported.exception.implicit.close: ResourceInterface.E1, r2
+ResourceInterface.java:38:23: compiler.err.unreported.exception.implicit.close: ResourceInterface.E1, r2
 1 error
--- a/test/tools/javac/TryWithResources/TwrFlow.out	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/TryWithResources/TwrFlow.out	Sun Feb 26 16:05:18 2012 -0800
@@ -1,3 +1,3 @@
 TwrFlow.java:14:11: compiler.err.except.never.thrown.in.try: java.io.IOException
-TwrFlow.java:12:13: compiler.err.unreported.exception.implicit.close: CustomCloseException, twrFlow
+TwrFlow.java:12:21: compiler.err.unreported.exception.implicit.close: CustomCloseException, twrFlow
 2 errors
--- a/test/tools/javac/TryWithResources/TwrLint.out	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/TryWithResources/TwrLint.out	Sun Feb 26 16:05:18 2012 -0800
@@ -1,3 +1,3 @@
 TwrLint.java:14:15: compiler.warn.try.explicit.close.call
-TwrLint.java:13:13: compiler.warn.try.resource.not.referenced: r3
+TwrLint.java:13:21: compiler.warn.try.resource.not.referenced: r3
 2 warnings
--- a/test/tools/javac/TryWithResources/TwrOnNonResource.out	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/TryWithResources/TwrOnNonResource.out	Sun Feb 26 16:05:18 2012 -0800
@@ -1,4 +1,4 @@
-TwrOnNonResource.java:12:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:15:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:18:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:12:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:15:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:18:30: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
 3 errors
--- a/test/tools/javac/TryWithResources/UnusedResourcesTest.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/TryWithResources/UnusedResourcesTest.java	Sun Feb 26 16:05:18 2012 -0800
@@ -28,6 +28,7 @@
  */
 
 import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper;
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.util.JCDiagnostic;
 import java.net.URI;
@@ -236,7 +237,7 @@
         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();
+                String varName = unwrap(diagnostic).getArgs()[0].toString();
                 if (varName.equals(TwrStmt.TWR1.resourceName)) {
                     unused_r1 = true;
                 } else if (varName.equals(TwrStmt.TWR2.resourceName)) {
@@ -246,5 +247,13 @@
                 }
             }
         }
+
+        private JCDiagnostic unwrap(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic instanceof JCDiagnostic)
+                return (JCDiagnostic) diagnostic;
+            if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper)
+                return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d;
+            throw new IllegalArgumentException();
+        }
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/T7043371.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7043371
+ * @summary javac7 fails with NPE during compilation
+ * @compile T7043371.java
+ */
+
+@interface Anno {
+    String value();
+}
+
+class B {
+    @Anno(value=A.a)
+    public static final int b = 0;
+}
+
+class A {
+    @Deprecated
+    public static final String a = "a";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/T7073477.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 7073477
+ * @summary NPE in com.sun.tools.javac.code.Symbol$VarSymbol.getConstValue
+ * @compile T7073477.java
+ */
+
+@SuppressWarnings(T7073477A.S)
+class T7073477 {
+}
+
+class T7073477A {
+  @SuppressWarnings("")
+  static final String S = "";
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/api/7086261/T7086261.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 20011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This 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 7086261
+ * @summary javac doesn't report error as expected, it only reports ClientCodeWrapper$DiagnosticSourceUnwrapper
+ */
+
+import javax.tools.*;
+
+import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper;
+import com.sun.tools.javac.util.JCDiagnostic;
+
+import java.net.URI;
+import java.util.Arrays;
+
+import static javax.tools.StandardLocation.*;
+import static javax.tools.JavaFileObject.Kind.*;
+
+
+public class T7086261 {
+
+    static class ErroneousSource extends SimpleJavaFileObject {
+        public ErroneousSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+        }
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return "class Test { NonexistentClass c = null; }";
+        }
+    }
+
+    static class DiagnosticChecker implements DiagnosticListener<javax.tools.JavaFileObject> {
+        public void report(Diagnostic message) {
+            if (!(message instanceof DiagnosticSourceUnwrapper)) {
+                throw new AssertionError("Wrapped diagnostic expected!");
+            }
+            String actual = message.toString();
+            JCDiagnostic jd = (JCDiagnostic)((DiagnosticSourceUnwrapper)message).d;
+            String expected = jd.toString();
+            if (!actual.equals(expected)) {
+                throw new AssertionError("expected = " + expected + "\nfound = " + actual);
+            }
+        }
+    };
+
+    void test() throws Throwable {
+        JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
+        JavaFileManager jfm = javac.getStandardFileManager(null, null, null);
+        JavaCompiler.CompilationTask task =
+                javac.getTask(null, jfm, new DiagnosticChecker(), null, null, Arrays.asList(new ErroneousSource()));
+        task.call();
+    }
+
+    public static void main(String[] args) throws Throwable {
+        new T7086261().test();
+    }
+}
--- a/test/tools/javac/diags/Example.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/diags/Example.java	Sun Feb 26 16:05:18 2012 -0800
@@ -21,10 +21,12 @@
  * questions.
  */
 
-import com.sun.tools.javac.file.JavacFileManager;
 import java.io.*;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.*;
 import java.util.regex.*;
+import javax.annotation.processing.Processor;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
 import javax.tools.JavaCompiler;
@@ -37,12 +39,11 @@
 // import com.sun.tools.javac.Main
 // import com.sun.tools.javac.main.Main
 
+import com.sun.tools.javac.api.ClientCodeWrapper;
+import com.sun.tools.javac.file.JavacFileManager;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JavacMessages;
 import com.sun.tools.javac.util.JCDiagnostic;
-import java.net.URL;
-import java.net.URLClassLoader;
-import javax.annotation.processing.Processor;
 
 /**
  * Class to handle example code designed to illustrate javac diagnostic messages.
@@ -397,7 +398,7 @@
 
             if (keys != null) {
                 for (Diagnostic<? extends JavaFileObject> d: dc.getDiagnostics()) {
-                    scanForKeys((JCDiagnostic) d, keys);
+                    scanForKeys(unwrap(d), keys);
                 }
             }
 
@@ -418,6 +419,14 @@
             for (JCDiagnostic sd: d.getSubdiagnostics())
                 scanForKeys(sd, keys);
         }
+
+        private JCDiagnostic unwrap(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic instanceof JCDiagnostic)
+                return (JCDiagnostic) diagnostic;
+            if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper)
+                return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d;
+            throw new IllegalArgumentException();
+        }
     }
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/CannotCreateArrayWithDiamond.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,28 @@
+/*
+ * 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.cannot.create.array.with.diamond
+
+class CannotCreateArrayWithDiamond {
+    Object[] array = new Object<>[3];
+}
--- a/test/tools/javac/diags/examples/EmptyCharLiteral.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/diags/examples/EmptyCharLiteral.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,6 @@
 
 // key: compiler.err.empty.char.lit
 // key: compiler.err.unclosed.char.lit
-// key: compiler.err.expected
 // key: compiler.err.premature.eof
 
 class X {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver15.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6970584 7060926
+ * @summary Attr.PostAttrAnalyzer misses a case
+ *
+ * @compile/fail/ref=FailOver15.out -XDrawDiagnostics -XDshouldStopPolicy=FLOW -XDdev FailOver15.java
+ */
+
+class Test {
+    void m() {
+        new UnknownClass<String, Void>() {
+            public String getString() {
+                String s = "";
+                s += "more";
+                return s;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/failover/FailOver15.out	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,3 @@
+FailOver15.java:17:10: compiler.err.expected: ';'
+FailOver15.java:11:13: compiler.err.cant.resolve.location: kindname.class, UnknownClass, , , (compiler.misc.location: kindname.class, Test, null)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/file/T7068437.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,136 @@
+/*
+ * 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 7068437
+ * @summary Filer.getResource(SOURCE_OUTPUT, ...) no longer works in JDK 7 w/o -s
+ */
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedOptions;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+public class T7068437 {
+    public static void main(String[] args) throws Exception {
+        new T7068437().run();
+    }
+
+    void run() throws Exception {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        System.err.println("using " + compiler.getClass()
+                + " from " + compiler.getClass().getProtectionDomain().getCodeSource());
+
+        CompilationTask task = compiler.getTask(null, null, null,
+                Collections.singleton("-proc:only"),
+                Collections.singleton("java.lang.Object"),
+                null);
+        task.setProcessors(Collections.singleton(new Proc()));
+        check("compilation", task.call());
+
+        task = compiler.getTask(null, null, null,
+                Arrays.asList("-proc:only", "-AexpectFile"),
+                Collections.singleton("java.lang.Object"),
+                null);
+        task.setProcessors(Collections.singleton(new Proc()));
+        check("compilation", task.call());
+    }
+
+    void check(String msg, boolean ok) {
+        System.err.println(msg + ": " + (ok ? "ok" : "failed"));
+        if (!ok)
+            throw new AssertionError(msg);
+    }
+
+    @SupportedAnnotationTypes("*")
+    @SupportedOptions("expectFile")
+    private static class Proc extends AbstractProcessor {
+        int count;
+
+        @Override
+        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.processingOver() || count++ > 0) {
+                return false;
+            }
+
+            Filer filer = processingEnv.getFiler();
+            Messager messager = processingEnv.getMessager();
+            Map<String, String> options = processingEnv.getOptions();
+                System.err.println(options);
+            boolean expectFile = options.containsKey("expectFile");
+
+            System.err.println("running Proc: expectFile=" + expectFile);
+
+            boolean found;
+            try {
+                messager.printMessage(Kind.NOTE, "found previous content of length " +
+                        filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length());
+                found = true;
+            } catch (FileNotFoundException x) {
+                messager.printMessage(Kind.NOTE, "not previously there");
+                found = false;
+            } catch (IOException x) {
+                messager.printMessage(Kind.ERROR, "while reading: " + x);
+                found = false;
+            }
+
+            if (expectFile && !found) {
+                messager.printMessage(Kind.ERROR, "expected file but file not found");
+            }
+
+            try {
+                Writer w = filer.createSourceFile("p.C").openWriter();
+                w.write("/* hello! */ package p; class C {}");
+                w.close();
+                messager.printMessage(Kind.NOTE, "wrote new content");
+            } catch (IOException x) {
+                messager.printMessage(Kind.ERROR, "while writing: " + x);
+            }
+
+            return true;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/file/T7068451.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,168 @@
+/*
+ * 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 7068451
+ * @summary Regression: javac compiles fixed sources against previous,
+ *              not current, version of generated sources
+ */
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaCompiler.CompilationTask;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+public class T7068451 {
+    public static void main(String[] args) throws Exception {
+        new T7068451().run();
+    }
+
+    void run() throws Exception {
+        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+        System.err.println("using " + compiler.getClass() + " from " + compiler.getClass().getProtectionDomain().getCodeSource());
+
+        File tmp = new File("tmp");
+        tmp.mkdir();
+        for (File f: tmp.listFiles())
+            f.delete();
+
+        File input = writeFile(tmp, "X.java", "package p; class X { { p.C.first(); } }");
+
+        List<String> opts = Arrays.asList(
+                "-s", tmp.getPath(),
+                "-d", tmp.getPath(),
+                "-XprintRounds");
+
+        System.err.println();
+        System.err.println("FIRST compilation");
+        System.err.println();
+
+        CompilationTask task = compiler.getTask(null, null, null, opts, null,
+                compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
+        task.setProcessors(Collections.singleton(new Proc("first")));
+        check("compilation", task.call());
+
+        writeFile(tmp, "X.java", "package p; class X { { p.C.second(); } }");
+
+        //Thread.sleep(2000);
+
+        System.err.println();
+        System.err.println("SECOND compilation");
+        System.err.println();
+
+        task = compiler.getTask(null, null, null, opts, null,
+                compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
+        task.setProcessors(Collections.singleton(new Proc("second")));
+        check("compilation", task.call());
+
+        //Thread.sleep(2000);
+
+        System.err.println();
+        System.err.println("SECOND compilation, REPEATED");
+        System.err.println();
+
+        task = compiler.getTask(null, null, null, opts, null,
+                compiler.getStandardFileManager(null, null, null).getJavaFileObjects(input));
+        task.setProcessors(Collections.singleton(new Proc("second")));
+        check("compilation", task.call());
+    }
+
+    void check(String msg, boolean ok) {
+        System.err.println(msg + ": " + (ok ? "ok" : "failed"));
+        if (!ok)
+            throw new AssertionError(msg);
+    }
+
+    static File writeFile(File base, String path, String body) throws IOException {
+        File f = new File(base, path);
+        FileWriter out = new FileWriter(f);
+        out.write(body);
+        out.close();
+        System.err.println("wrote " + path + ": " + body);
+        return f;
+    }
+
+    @SupportedAnnotationTypes("*")
+    private static class Proc extends AbstractProcessor {
+        final String m;
+        Proc(String m) {
+            this.m = m;
+        }
+
+        int count;
+        @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.processingOver() || count++ > 0) {
+                return false;
+            }
+
+            Filer filer = processingEnv.getFiler();
+            Messager messager = processingEnv.getMessager();
+
+            System.err.println("running Proc");
+            try {
+                int len = filer.getResource(StandardLocation.SOURCE_OUTPUT, "p", "C.java").getCharContent(false).length();
+                messager.printMessage(Kind.NOTE, "C.java: found previous content of length " + len);
+            } catch (FileNotFoundException x) {
+                messager.printMessage(Kind.NOTE, "C.java: not previously there");
+            } catch (IOException x) {
+                messager.printMessage(Kind.ERROR, "while reading: " + x);
+            }
+
+            try {
+                String body = "package p; public class C { public static void " + m + "() {} }";
+                Writer w = filer.createSourceFile("p.C").openWriter();
+                w.write(body);
+                w.close();
+                messager.printMessage(Kind.NOTE, "C.java: wrote new content: " + body);
+            } catch (IOException x) {
+                messager.printMessage(Kind.ERROR, "while writing: " + x);
+            }
+
+            return true;
+        }
+
+        @Override
+        public SourceVersion getSupportedSourceVersion() {
+            return SourceVersion.latest();
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/diamond/7046778/DiamondAndInnerClassTest.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,336 @@
+/*
+ * 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 7046778
+ * @summary Project Coin: problem with diamond and member inner classes
+ */
+
+import com.sun.source.util.JavacTask;
+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 DiamondAndInnerClassTest {
+
+    static int checkCount = 0;
+
+    enum TypeArgumentKind {
+        NONE(""),
+        STRING("<String>"),
+        INTEGER("<Integer>"),
+        DIAMOND("<>");
+
+        String typeargStr;
+
+        private TypeArgumentKind(String typeargStr) {
+            this.typeargStr = typeargStr;
+        }
+
+        boolean compatible(TypeArgumentKind that) {
+            switch (this) {
+                case NONE: return true;
+                case STRING: return that != INTEGER;
+                case INTEGER: return that != STRING;
+                default: throw new AssertionError("Unexpected decl kind: " + this);
+            }
+        }
+
+        boolean compatible(ArgumentKind that) {
+            switch (this) {
+                case NONE: return true;
+                case STRING: return that == ArgumentKind.STRING;
+                case INTEGER: return that == ArgumentKind.INTEGER;
+                default: throw new AssertionError("Unexpected decl kind: " + this);
+            }
+        }
+    }
+
+    enum ArgumentKind {
+        OBJECT("(Object)null"),
+        STRING("(String)null"),
+        INTEGER("(Integer)null");
+
+        String argStr;
+
+        private ArgumentKind(String argStr) {
+            this.argStr = argStr;
+        }
+    }
+
+    enum TypeQualifierArity {
+        ONE(1, "A1#TA1"),
+        TWO(2, "A1#TA1.A2#TA2"),
+        THREE(3, "A1#TA1.A2#TA2.A3#TA3");
+
+        int n;
+        String qualifierStr;
+
+        private TypeQualifierArity(int n, String qualifierStr) {
+            this.n = n;
+            this.qualifierStr = qualifierStr;
+        }
+
+        String getType(TypeArgumentKind... typeArgumentKinds) {
+            String res = qualifierStr;
+            for (int i = 1 ; i <= typeArgumentKinds.length ; i++) {
+                res = res.replace("#TA" + i, typeArgumentKinds[i-1].typeargStr);
+            }
+            return res;
+        }
+
+        boolean matches(InnerClassDeclArity innerClassDeclArity) {
+            return n ==innerClassDeclArity.n;
+        }
+    }
+
+    enum InnerClassDeclArity {
+        ONE(1, "class A1<X> { A1(X x1) { } #B }"),
+        TWO(2, "class A1<X1> { class A2<X2> { A2(X1 x1, X2 x2) { }  #B } }"),
+        THREE(3, "class A1<X1> { class A2<X2> { class A3<X3> { A3(X1 x1, X2 x2, X3 x3) { } #B } } }");
+
+        int n;
+        String classDeclStr;
+
+        private InnerClassDeclArity(int n, String classDeclStr) {
+            this.n = n;
+            this.classDeclStr = classDeclStr;
+        }
+    }
+
+    enum ArgumentListArity {
+        ONE(1, "(#A1)"),
+        TWO(2, "(#A1,#A2)"),
+        THREE(3, "(#A1,#A2,#A3)");
+
+        int n;
+        String argListStr;
+
+        private ArgumentListArity(int n, String argListStr) {
+            this.n = n;
+            this.argListStr = argListStr;
+        }
+
+        String getArgs(ArgumentKind... argumentKinds) {
+            String res = argListStr;
+            for (int i = 1 ; i <= argumentKinds.length ; i++) {
+                res = res.replace("#A" + i, argumentKinds[i-1].argStr);
+            }
+            return res;
+        }
+
+        boolean matches(InnerClassDeclArity innerClassDeclArity) {
+            return n ==innerClassDeclArity.n;
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (InnerClassDeclArity innerClassDeclArity : InnerClassDeclArity.values()) {
+            for (TypeQualifierArity declType : TypeQualifierArity.values()) {
+                if (!declType.matches(innerClassDeclArity)) continue;
+                for (TypeQualifierArity newClassType : TypeQualifierArity.values()) {
+                    if (!newClassType.matches(innerClassDeclArity)) continue;
+                    for (ArgumentListArity argList : ArgumentListArity.values()) {
+                        if (!argList.matches(innerClassDeclArity)) continue;
+                        for (TypeArgumentKind taDecl1 : TypeArgumentKind.values()) {
+                            boolean isDeclRaw = taDecl1 == TypeArgumentKind.NONE;
+                            //no diamond on decl site
+                            if (taDecl1 == TypeArgumentKind.DIAMOND) continue;
+                            for (TypeArgumentKind taSite1 : TypeArgumentKind.values()) {
+                                boolean isSiteRaw = taSite1 == TypeArgumentKind.NONE;
+                                //diamond only allowed on the last type qualifier
+                                if (taSite1 == TypeArgumentKind.DIAMOND &&
+                                        innerClassDeclArity != InnerClassDeclArity.ONE) continue;
+                                for (ArgumentKind arg1 : ArgumentKind.values()) {
+                                    if (innerClassDeclArity == innerClassDeclArity.ONE) {
+                                        new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
+                                                argList, new TypeArgumentKind[] {taDecl1},
+                                                new TypeArgumentKind[] {taSite1}, new ArgumentKind[] {arg1}).run(comp, fm);
+                                        continue;
+                                    }
+                                    for (TypeArgumentKind taDecl2 : TypeArgumentKind.values()) {
+                                        //no rare types
+                                        if (isDeclRaw != (taDecl2 == TypeArgumentKind.NONE)) continue;
+                                        //no diamond on decl site
+                                        if (taDecl2 == TypeArgumentKind.DIAMOND) continue;
+                                        for (TypeArgumentKind taSite2 : TypeArgumentKind.values()) {
+                                            //no rare types
+                                            if (isSiteRaw != (taSite2 == TypeArgumentKind.NONE)) continue;
+                                            //diamond only allowed on the last type qualifier
+                                            if (taSite2 == TypeArgumentKind.DIAMOND &&
+                                                    innerClassDeclArity != InnerClassDeclArity.TWO) continue;
+                                            for (ArgumentKind arg2 : ArgumentKind.values()) {
+                                                if (innerClassDeclArity == innerClassDeclArity.TWO) {
+                                                    new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
+                                                            argList, new TypeArgumentKind[] {taDecl1, taDecl2},
+                                                            new TypeArgumentKind[] {taSite1, taSite2},
+                                                            new ArgumentKind[] {arg1, arg2}).run(comp, fm);
+                                                    continue;
+                                                }
+                                                for (TypeArgumentKind taDecl3 : TypeArgumentKind.values()) {
+                                                    //no rare types
+                                                    if (isDeclRaw != (taDecl3 == TypeArgumentKind.NONE)) continue;
+                                                    //no diamond on decl site
+                                                    if (taDecl3 == TypeArgumentKind.DIAMOND) continue;
+                                                    for (TypeArgumentKind taSite3 : TypeArgumentKind.values()) {
+                                                        //no rare types
+                                                        if (isSiteRaw != (taSite3 == TypeArgumentKind.NONE)) continue;
+                                                        //diamond only allowed on the last type qualifier
+                                                        if (taSite3 == TypeArgumentKind.DIAMOND &&
+                                                                innerClassDeclArity != InnerClassDeclArity.THREE) continue;
+                                                        for (ArgumentKind arg3 : ArgumentKind.values()) {
+                                                            if (innerClassDeclArity == innerClassDeclArity.THREE) {
+                                                                new DiamondAndInnerClassTest(innerClassDeclArity, declType, newClassType,
+                                                                        argList, new TypeArgumentKind[] {taDecl1, taDecl2, taDecl3},
+                                                                        new TypeArgumentKind[] {taSite1, taSite2, taSite3},
+                                                                        new ArgumentKind[] {arg1, arg2, arg3}).run(comp, fm);
+                                                                continue;
+                                                            }
+                                                        }
+                                                    }
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    InnerClassDeclArity innerClassDeclArity;
+    TypeQualifierArity declType;
+    TypeQualifierArity siteType;
+    ArgumentListArity argList;
+    TypeArgumentKind[] declTypeArgumentKinds;
+    TypeArgumentKind[] siteTypeArgumentKinds;
+    ArgumentKind[] argumentKinds;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    DiamondAndInnerClassTest(InnerClassDeclArity innerClassDeclArity,
+            TypeQualifierArity declType, TypeQualifierArity siteType, ArgumentListArity argList,
+            TypeArgumentKind[] declTypeArgumentKinds, TypeArgumentKind[] siteTypeArgumentKinds,
+            ArgumentKind[] argumentKinds) {
+        this.innerClassDeclArity = innerClassDeclArity;
+        this.declType = declType;
+        this.siteType = siteType;
+        this.argList = argList;
+        this.declTypeArgumentKinds = declTypeArgumentKinds;
+        this.siteTypeArgumentKinds = siteTypeArgumentKinds;
+        this.argumentKinds = argumentKinds;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String bodyTemplate = "#D res = new #S#AL;";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = innerClassDeclArity.classDeclStr.replace("#B", bodyTemplate)
+                             .replace("#D", declType.getType(declTypeArgumentKinds))
+                             .replace("#S", siteType.getType(siteTypeArgumentKinds))
+                             .replace("#AL", argList.getArgs(argumentKinds));
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        boolean errorExpected = false;
+
+        TypeArgumentKind[] expectedArgKinds = new TypeArgumentKind[innerClassDeclArity.n];
+
+        for (int i = 0 ; i < innerClassDeclArity.n ; i++) {
+            if (!declTypeArgumentKinds[i].compatible(siteTypeArgumentKinds[i])) {
+                errorExpected = true;
+                break;
+            }
+            expectedArgKinds[i] = siteTypeArgumentKinds[i] == TypeArgumentKind.DIAMOND ?
+                declTypeArgumentKinds[i] : siteTypeArgumentKinds[i];
+        }
+
+        if (!errorExpected) {
+            for (int i = 0 ; i < innerClassDeclArity.n ; i++) {
+                //System.out.println("check " + expectedArgKinds[i] + " against " + argumentKinds[i]);
+                if (!expectedArgKinds[i].compatible(argumentKinds[i])) {
+                    errorExpected = true;
+                    break;
+                }
+            }
+        }
+
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/diamond/7057297/T7057297.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,29 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 7057297
+ *
+ * @summary Project Coin: diamond erroneously accepts in array initializer expressions
+ * @compile/fail/ref=T7057297.out T7057297.java -XDrawDiagnostics
+ *
+ */
+
+class T7205797<X> {
+
+    class Inner<Y> {}
+
+    T7205797<String>[] o1 = new T7205797<>[1]; //error
+    T7205797<String>[] o2 = new T7205797<>[1][1]; //error
+    T7205797<String>[] o3 = new T7205797<>[1][1][1]; //error
+
+    T7205797<String>[] o4 = new T7205797<>[] { }; //error
+    T7205797<String>[] o5 = new T7205797<>[][] { }; //error
+    T7205797<String>[] o6 = new T7205797<>[][][] { }; //error
+
+    T7205797<String>.Inner<String>[] o1 = new T7205797<String>.Inner<>[1]; //error
+    T7205797<String>.Inner<String>[] o2 = new T7205797<String>.Inner<>[1][1]; //error
+    T7205797<String>.Inner<String>[] o3 = new T7205797<String>.Inner<>[1][1][1]; //error
+
+    T7205797<String>.Inner<String>[] o4 = new T7205797<String>.Inner<>[] { }; //error
+    T7205797<String>.Inner<String>[] o5 = new T7205797<String>.Inner<>[][] { }; //error
+    T7205797<String>.Inner<String>[] o6 = new T7205797<String>.Inner<>[][][] { }; //error
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/diamond/7057297/T7057297.out	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,13 @@
+T7057297.java:14:41: compiler.err.cannot.create.array.with.diamond
+T7057297.java:15:41: compiler.err.cannot.create.array.with.diamond
+T7057297.java:16:41: compiler.err.cannot.create.array.with.diamond
+T7057297.java:18:41: compiler.err.cannot.create.array.with.diamond
+T7057297.java:19:41: compiler.err.cannot.create.array.with.diamond
+T7057297.java:20:41: compiler.err.cannot.create.array.with.diamond
+T7057297.java:22:69: compiler.err.cannot.create.array.with.diamond
+T7057297.java:23:69: compiler.err.cannot.create.array.with.diamond
+T7057297.java:24:69: compiler.err.cannot.create.array.with.diamond
+T7057297.java:26:69: compiler.err.cannot.create.array.with.diamond
+T7057297.java:27:69: compiler.err.cannot.create.array.with.diamond
+T7057297.java:28:69: compiler.err.cannot.create.array.with.diamond
+12 errors
--- a/test/tools/javac/generics/diamond/neg/Neg09.out	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/generics/diamond/neg/Neg09.out	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
-Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member)
-Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested)
-Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member, (compiler.misc.diamond.and.anon.class: Neg09.Member)
-Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested, (compiler.misc.diamond.and.anon.class: Neg09.Nested)
+Neg09.java:17:34: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
+Neg09.java:18:34: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
+Neg09.java:22:39: compiler.err.cant.apply.diamond.1: Neg09.Member<X>, (compiler.misc.diamond.and.anon.class: Neg09.Member<X>)
+Neg09.java:23:40: compiler.err.cant.apply.diamond.1: Neg09.Nested<X>, (compiler.misc.diamond.and.anon.class: Neg09.Nested<X>)
 4 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7062745/GenericOverrideTest.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,286 @@
+/*
+ * 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 7062745
+ * @summary  Regression: difference in overload resolution when two methods are maximally specific
+ */
+
+import com.sun.source.util.JavacTask;
+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 GenericOverrideTest {
+
+    static int checkCount = 0;
+
+    enum SignatureKind {
+        NON_GENERIC(""),
+        GENERIC("<X>");
+
+        String paramStr;
+
+        private SignatureKind(String paramStr) {
+            this.paramStr = paramStr;
+        }
+    }
+
+    enum ReturnTypeKind {
+        LIST("List"),
+        ARRAYLIST("ArrayList");
+
+        String retStr;
+
+        private ReturnTypeKind(String retStr) {
+            this.retStr = retStr;
+        }
+
+        boolean moreSpecificThan(ReturnTypeKind that) {
+            switch (this) {
+                case LIST:
+                    return that == this;
+                case ARRAYLIST:
+                    return that == LIST || that == ARRAYLIST;
+                default: throw new AssertionError("Unexpected ret kind: " + this);
+            }
+        }
+    }
+
+    enum TypeArgumentKind {
+        NONE(""),
+        UNBOUND("<?>"),
+        INTEGER("<Number>"),
+        NUMBER("<Integer>"),
+        TYPEVAR("<X>");
+
+        String typeargStr;
+
+        private TypeArgumentKind(String typeargStr) {
+            this.typeargStr = typeargStr;
+        }
+
+        boolean compatibleWith(SignatureKind sig) {
+            switch (this) {
+                case TYPEVAR: return sig != SignatureKind.NON_GENERIC;
+                default: return true;
+            }
+        }
+
+        boolean moreSpecificThan(TypeArgumentKind that, boolean strict) {
+            switch (this) {
+                case NONE:
+                    return that == this || !strict;
+                case UNBOUND:
+                    return that == this || that == NONE;
+                case INTEGER:
+                case NUMBER:
+                case TYPEVAR:
+                    return that == this || that == NONE || that == UNBOUND;
+                default: throw new AssertionError("Unexpected typearg kind: " + this);
+            }
+        }
+
+        boolean assignableTo(TypeArgumentKind that, SignatureKind sig) {
+            switch (this) {
+                case NONE:
+                    //this case needs to workaround to javac's impl of 15.12.2.8 being too strict
+                    //ideally should be just 'return true' (see 7067746)
+                    return sig == SignatureKind.NON_GENERIC || that == NONE;
+                case UNBOUND:
+                    return that == this || that == NONE;
+                case INTEGER:
+                case NUMBER:
+                    return that == this || that == NONE || that == UNBOUND;
+                case TYPEVAR:
+                    return true;
+                default: throw new AssertionError("Unexpected typearg kind: " + this);
+            }
+        }
+    }
+
+    public static void main(String... args) throws Exception {
+
+        //create default shared JavaCompiler - reused across multiple compilations
+        JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
+
+        for (SignatureKind sig1 : SignatureKind.values()) {
+            for (ReturnTypeKind rt1 : ReturnTypeKind.values()) {
+                for (TypeArgumentKind ta1 : TypeArgumentKind.values()) {
+                    if (!ta1.compatibleWith(sig1)) continue;
+                    for (SignatureKind sig2 : SignatureKind.values()) {
+                        for (ReturnTypeKind rt2 : ReturnTypeKind.values()) {
+                            for (TypeArgumentKind ta2 : TypeArgumentKind.values()) {
+                                if (!ta2.compatibleWith(sig2)) continue;
+                                for (ReturnTypeKind rt3 : ReturnTypeKind.values()) {
+                                    for (TypeArgumentKind ta3 : TypeArgumentKind.values()) {
+                                        if (!ta3.compatibleWith(SignatureKind.NON_GENERIC)) continue;
+                                        new GenericOverrideTest(sig1, rt1, ta1, sig2, rt2, ta2, rt3, ta3).run(comp, fm);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        System.out.println("Total check executed: " + checkCount);
+    }
+
+    SignatureKind sig1, sig2;
+    ReturnTypeKind rt1, rt2, rt3;
+    TypeArgumentKind ta1, ta2, ta3;
+    JavaSource source;
+    DiagnosticChecker diagChecker;
+
+    GenericOverrideTest(SignatureKind sig1, ReturnTypeKind rt1, TypeArgumentKind ta1,
+            SignatureKind sig2, ReturnTypeKind rt2, TypeArgumentKind ta2, ReturnTypeKind rt3, TypeArgumentKind ta3) {
+        this.sig1 = sig1;
+        this.sig2 = sig2;
+        this.rt1 = rt1;
+        this.rt2 = rt2;
+        this.rt3 = rt3;
+        this.ta1 = ta1;
+        this.ta2 = ta2;
+        this.ta3 = ta3;
+        this.source = new JavaSource();
+        this.diagChecker = new DiagnosticChecker();
+    }
+
+    class JavaSource extends SimpleJavaFileObject {
+
+        String template = "import java.util.*;\n" +
+                          "interface A { #S1 #R1#TA1 m(); }\n" +
+                          "interface B { #S2 #R2#TA2 m(); }\n" +
+                          "interface AB extends A, B {}\n" +
+                          "class Test {\n" +
+                          "  void test(AB ab) { #R3#TA3 n = ab.m(); }\n" +
+                          "}";
+
+        String source;
+
+        public JavaSource() {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            source = template.replace("#S1", sig1.paramStr).
+                    replace("#S2", sig2.paramStr).
+                    replace("#R1", rt1.retStr).
+                    replace("#R2", rt2.retStr).
+                    replace("#R3", rt3.retStr).
+                    replace("#TA1", ta1.typeargStr).
+                    replace("#TA2", ta2.typeargStr).
+                    replace("#TA3", ta3.typeargStr);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    void run(JavaCompiler tool, StandardJavaFileManager fm) throws Exception {
+        JavacTask ct = (JavacTask)tool.getTask(null, fm, diagChecker,
+                null, null, Arrays.asList(source));
+        try {
+            ct.analyze();
+        } catch (Throwable ex) {
+            throw new AssertionError("Error thron when compiling the following code:\n" + source.getCharContent(true));
+        }
+        check();
+    }
+
+    void check() {
+        checkCount++;
+
+        boolean errorExpected = false;
+        int mostSpecific = 0;
+
+        //first check that either |R1| <: |R2| or |R2| <: |R1|
+        if (rt1 != rt2) {
+            if (!rt1.moreSpecificThan(rt2) &&
+                    !rt2.moreSpecificThan(rt1)) {
+                errorExpected = true;
+            } else {
+                mostSpecific = rt1.moreSpecificThan(rt2) ? 1 : 2;
+            }
+        }
+
+        //check that either TA1 <= TA2 or TA2 <= TA1 (unless most specific return found above is raw)
+        if (!errorExpected) {
+            if (ta1 != ta2) {
+                boolean useStrictCheck = ta1.moreSpecificThan(ta2, true) || ta2.moreSpecificThan(ta1, true);
+                if (!ta1.moreSpecificThan(ta2, useStrictCheck) &&
+                        !ta2.moreSpecificThan(ta1, useStrictCheck)) {
+                    errorExpected = true;
+                } else {
+                    int mostSpecific2 = ta1.moreSpecificThan(ta2, useStrictCheck) ? 1 : 2;
+                    if (mostSpecific != 0 && mostSpecific2 != mostSpecific) {
+                        errorExpected = mostSpecific == 1 ? ta1 != TypeArgumentKind.NONE : ta2 != TypeArgumentKind.NONE;
+                    } else {
+                        mostSpecific = mostSpecific2;
+                    }
+                }
+            } else if (mostSpecific == 0) {
+                //when no signature is better than the other, an arbitrary choice
+                //must be made - javac always picks the second signature
+                mostSpecific = 2;
+            }
+        }
+
+        //finally, check that most specific return type is compatible with expected type
+        if (!errorExpected) {
+            ReturnTypeKind msrt = mostSpecific == 1 ? rt1 : rt2;
+            TypeArgumentKind msta = mostSpecific == 1 ? ta1 : ta2;
+            SignatureKind mssig = mostSpecific == 1 ? sig1 : sig2;
+
+            if (!msrt.moreSpecificThan(rt3) ||
+                    !msta.assignableTo(ta3, mssig)) {
+                errorExpected = true;
+            }
+        }
+
+        if (errorExpected != diagChecker.errorFound) {
+            throw new Error("invalid diagnostics for source:\n" +
+                source.getCharContent(true) +
+                "\nFound error: " + diagChecker.errorFound +
+                "\nExpected error: " + errorExpected);
+        }
+    }
+
+    static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+        boolean errorFound;
+
+        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
+                errorFound = true;
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7062745/T7062745neg.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7062745
+ * @summary  Regression: difference in overload resolution when two methods are maximally specific
+ * @compile/fail/ref=T7062745neg.out -XDrawDiagnostics T7062745neg.java
+ */
+
+import java.util.*;
+
+class T7062745neg {
+    interface A { List<Number> getList(); }
+    interface B { ArrayList getList(); }
+    interface AB extends A, B {}
+
+    void test(AB ab) {
+        Number n = ab.getList().get(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7062745/T7062745neg.out	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,2 @@
+T7062745neg.java:16:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), java.lang.Object, java.lang.Number
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7062745/T7062745pos.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,42 @@
+/*
+ * 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 7062745
+ * @summary  Regression: difference in overload resolution when two methods are maximally specific
+ *
+ * @compile T7062745pos.java
+ */
+
+import java.util.*;
+
+class T7062745pos {
+    interface A { List<Number> getList(); }
+    interface B { List getList(); }
+    interface AB extends A, B {}
+
+    void test(AB ab) {
+        Number n = ab.getList().get(1);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lib/CompileFail.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+import java.io.*;
+import java.util.*;
+
+/*
+ * Utility class to emulate jtreg @compile/fail, but also checking the specific
+ * exit code, given as the first arg.
+ */
+public class CompileFail {
+    public static void main(String... args) {
+        if (args.length < 2)
+            throw new IllegalArgumentException("insufficient args");
+        int expected_rc = getReturnCode(args[0]);
+
+        List<String> javacArgs = new ArrayList<>();
+        javacArgs.addAll(Arrays.asList(
+            "-bootclasspath", System.getProperty("sun.boot.class.path"),
+            "-d", "."
+        ));
+
+        File testSrc = new File(System.getProperty("test.src"));
+        for (int i = 1; i < args.length; i++) {
+            String arg = args[i];
+            if (arg.endsWith(".java"))
+                javacArgs.add(new File(testSrc, arg).getPath());
+            else
+                javacArgs.add(arg);
+        }
+
+        int rc = com.sun.tools.javac.Main.compile(
+            javacArgs.toArray(new String[javacArgs.size()]));
+
+        if (rc != expected_rc)
+            throw new Error("unexpected exit code: " + rc
+                        + ", expected: " + expected_rc);
+    }
+
+    static int getReturnCode(String name) {
+        switch (name) {
+            case "OK":
+                return EXIT_OK;
+
+            case "ERROR":
+                return EXIT_ERROR;
+
+            case "CMDERR":
+                return EXIT_CMDERR;
+
+            case "SYSERR":
+                return EXIT_SYSERR;
+
+            case "ABNORMAL":
+                return EXIT_ABNORMAL;
+
+            default:
+                throw new IllegalArgumentException(name);
+        }
+    }
+
+    // The following is cut-n-paste from com.sun.tools.javac.main.Main
+    static final int
+        EXIT_OK = 0,        // Compilation completed with no errors.
+        EXIT_ERROR = 1,     // Completed but reported errors.
+        EXIT_CMDERR = 2,    // Bad command-line arguments
+        EXIT_SYSERR = 3,    // System error or resource exhaustion.
+        EXIT_ABNORMAL = 4;  // Compiler terminated abnormally
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/parser/StringFoldingTest.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,96 @@
+/*
+ * 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 7068902
+ * @summary verify that string folding can be enabled or disabled
+ */
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class StringFoldingTest {
+    final JavaCompiler tool;
+    final JavaSource source;
+
+    public StringFoldingTest() {
+        tool = ToolProvider.getSystemJavaCompiler();
+        source = new JavaSource();
+    }
+
+    static class JavaSource extends SimpleJavaFileObject {
+
+        final static String source =
+                "class C {String X=\"F\" + \"O\" + \"L\" + \"D\" + \"E\" + \"D\";}";
+
+        JavaSource() {
+            super(URI.create("myfo:/C.java"), JavaFileObject.Kind.SOURCE);
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+
+    public static void main(String... args) throws IOException {
+        StringFoldingTest t = new StringFoldingTest();
+        t.run(false);
+        t.run(true);
+    }
+
+    void run(boolean disableStringFolding) throws IOException {
+        List<String> argsList = new ArrayList<String>();
+        if (disableStringFolding) {
+            argsList.add("-XDallowStringFolding=false");
+        }
+        JavacTask ct = (JavacTask)tool.getTask(null, null, null,
+                argsList,
+                null,
+                Arrays.asList(source));
+        Iterable<? extends CompilationUnitTree> trees = ct.parse();
+        String text = trees.toString();
+        System.out.println(text);
+
+        if (disableStringFolding) {
+            if (text.contains("FOLDED")) {
+                throw new AssertionError("Expected string folding");
+            }
+        } else {
+            if (!text.contains("FOLDED")) {
+                throw new AssertionError("Expected no string folding");
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/parser/netbeans/JavacParserTest.java	Sun Feb 26 16:05:18 2012 -0800
@@ -0,0 +1,716 @@
+/*
+ * 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 7073631
+ * @summary tests error and diagnostics positions
+ * @author  jan.lahoda@oracle.com
+ */
+
+import com.sun.source.tree.BinaryTree;
+import com.sun.source.tree.BlockTree;
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.ExpressionStatementTree;
+import com.sun.source.tree.ExpressionTree;
+import com.sun.source.tree.MethodInvocationTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.ModifiersTree;
+import com.sun.source.tree.StatementTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.Tree.Kind;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.tree.WhileLoopTree;
+import com.sun.source.util.SourcePositions;
+import com.sun.source.util.TreeScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.tree.JCTree;
+import java.io.IOException;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticCollector;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class JavacParserTest extends TestCase {
+    final JavaCompiler tool;
+    public JavacParserTest(String testName) {
+        tool = ToolProvider.getSystemJavaCompiler();
+        System.out.println("java.home=" + System.getProperty("java.home"));
+    }
+
+    static class MyFileObject extends SimpleJavaFileObject {
+
+        private String text;
+
+        public MyFileObject(String text) {
+            super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+            this.text = text;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return text;
+        }
+    }
+
+    public void testPositionForSuperConstructorCalls() throws IOException {
+        assert tool != null;
+
+        String code = "package test; public class Test {public Test() {super();}}";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+        MethodTree method =
+                (MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0);
+        ExpressionStatementTree es =
+                (ExpressionStatementTree) method.getBody().getStatements().get(0);
+
+        assertEquals("testPositionForSuperConstructorCalls",
+                72 - 24, pos.getStartPosition(cut, es));
+        assertEquals("testPositionForSuperConstructorCalls",
+                80 - 24, pos.getEndPosition(cut, es));
+
+        MethodInvocationTree mit = (MethodInvocationTree) es.getExpression();
+
+        assertEquals("testPositionForSuperConstructorCalls",
+                72 - 24, pos.getStartPosition(cut, mit));
+        assertEquals("testPositionForSuperConstructorCalls",
+                79 - 24, pos.getEndPosition(cut, mit));
+
+        assertEquals("testPositionForSuperConstructorCalls",
+                72 - 24, pos.getStartPosition(cut, mit.getMethodSelect()));
+        assertEquals("testPositionForSuperConstructorCalls",
+                77 - 24, pos.getEndPosition(cut, mit.getMethodSelect()));
+
+    }
+
+    public void testPositionForEnumModifiers() throws IOException {
+
+        String code = "package test; public enum Test {A;}";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        ModifiersTree mt = clazz.getModifiers();
+
+        assertEquals("testPositionForEnumModifiers",
+                38 - 24, pos.getStartPosition(cut, mt));
+        assertEquals("testPositionForEnumModifiers",
+                44 - 24, pos.getEndPosition(cut, mt));
+    }
+
+    public void testNewClassWithEnclosing() throws IOException {
+
+
+        String code = "package test; class Test { " +
+                "class d {} private void method() { " +
+                "Object o = Test.this.new d(); } }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        SourcePositions pos = Trees.instance(ct).getSourcePositions();
+
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        ExpressionTree est =
+                ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
+
+        assertEquals("testNewClassWithEnclosing",
+                97 - 24, pos.getStartPosition(cut, est));
+        assertEquals("testNewClassWithEnclosing",
+                114 - 24, pos.getEndPosition(cut, est));
+    }
+
+    public void testPreferredPositionForBinaryOp() throws IOException {
+
+        String code = "package test; public class Test {" +
+                "private void test() {" +
+                "Object o = null; boolean b = o != null && o instanceof String;" +
+                "} private Test() {}}";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        MethodTree method = (MethodTree) clazz.getMembers().get(0);
+        VariableTree condSt = (VariableTree) method.getBody().getStatements().get(1);
+        BinaryTree cond = (BinaryTree) condSt.getInitializer();
+
+        JCTree condJC = (JCTree) cond;
+
+        assertEquals("testNewClassWithEnclosing",
+                117 - 24, condJC.pos);
+    }
+
+    public void testPositionBrokenSource126732a() throws IOException {
+        String[] commands = new String[]{
+            "return Runnable()",
+            "do { } while (true)",
+            "throw UnsupportedOperationException()",
+            "assert true",
+            "1 + 1",};
+
+        for (String command : commands) {
+
+            String code = "package test;\n"
+                    + "public class Test {\n"
+                    + "    public static void test() {\n"
+                    + "        " + command + " {\n"
+                    + "                new Runnable() {\n"
+                    + "        };\n"
+                    + "    }\n"
+                    + "}";
+            JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+                    null, null, Arrays.asList(new MyFileObject(code)));
+            CompilationUnitTree cut = ct.parse().iterator().next();
+
+            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+            MethodTree method = (MethodTree) clazz.getMembers().get(0);
+            List<? extends StatementTree> statements =
+                    method.getBody().getStatements();
+
+            StatementTree ret = statements.get(0);
+            StatementTree block = statements.get(1);
+
+            Trees t = Trees.instance(ct);
+            int len = code.indexOf(command + " {") + (command + " ").length();
+            assertEquals(command, len,
+                    t.getSourcePositions().getEndPosition(cut, ret));
+            assertEquals(command, len,
+                    t.getSourcePositions().getStartPosition(cut, block));
+        }
+    }
+
+    public void testPositionBrokenSource126732b() throws IOException {
+        String[] commands = new String[]{
+            "break",
+            "break A",
+            "continue ",
+            "continue A",};
+
+        for (String command : commands) {
+
+            String code = "package test;\n"
+                    + "public class Test {\n"
+                    + "    public static void test() {\n"
+                    + "        while (true) {\n"
+                    + "            " + command + " {\n"
+                    + "                new Runnable() {\n"
+                    + "        };\n"
+                    + "        }\n"
+                    + "    }\n"
+                    + "}";
+
+            JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null,
+                    null, null, Arrays.asList(new MyFileObject(code)));
+            CompilationUnitTree cut = ct.parse().iterator().next();
+
+            ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+            MethodTree method = (MethodTree) clazz.getMembers().get(0);
+            List<? extends StatementTree> statements =
+                    ((BlockTree) ((WhileLoopTree) method.getBody().getStatements().get(0)).getStatement()).getStatements();
+
+            StatementTree ret = statements.get(0);
+            StatementTree block = statements.get(1);
+
+            Trees t = Trees.instance(ct);
+            int len = code.indexOf(command + " {") + (command + " ").length();
+            assertEquals(command, len,
+                    t.getSourcePositions().getEndPosition(cut, ret));
+            assertEquals(command, len,
+                    t.getSourcePositions().getStartPosition(cut, block));
+        }
+    }
+
+    public void testErrorRecoveryForEnhancedForLoop142381() throws IOException {
+
+        String code = "package test; class Test { " +
+                "private void method() { " +
+                "java.util.Set<String> s = null; for (a : s) {} } }";
+
+        final List<Diagnostic<? extends JavaFileObject>> errors =
+                new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+                new DiagnosticListener<JavaFileObject>() {
+            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                errors.add(diagnostic);
+            }
+        }, null, null, Arrays.asList(new MyFileObject(code)));
+
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        StatementTree forStatement =
+                ((MethodTree) clazz.getMembers().get(0)).getBody().getStatements().get(1);
+
+        assertEquals("testErrorRecoveryForEnhancedForLoop142381",
+                Kind.ENHANCED_FOR_LOOP, forStatement.getKind());
+        assertFalse("testErrorRecoveryForEnhancedForLoop142381", errors.isEmpty());
+    }
+
+    public void testPositionAnnotationNoPackage187551() throws IOException {
+
+        String code = "\n@interface Test {}";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        Trees t = Trees.instance(ct);
+
+        assertEquals("testPositionAnnotationNoPackage187551",
+                1, t.getSourcePositions().getStartPosition(cut, clazz));
+    }
+
+    public void testPositionsSane() throws IOException {
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? extends java.util.List<? extends String>> l; " +
+                "} }");
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? super java.util.List<? super String>> l; " +
+                "} }");
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? super java.util.List<?>> l; } }");
+    }
+
+    private void performPositionsSanityTest(String code) throws IOException {
+
+        final List<Diagnostic<? extends JavaFileObject>> errors =
+                new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+                new DiagnosticListener<JavaFileObject>() {
+
+            public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                errors.add(diagnostic);
+            }
+        }, null, null, Arrays.asList(new MyFileObject(code)));
+
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+        final Trees trees = Trees.instance(ct);
+
+        new TreeScanner<Void, Void>() {
+
+            private long parentStart = 0;
+            private long parentEnd = Integer.MAX_VALUE;
+
+            @Override
+            public Void scan(Tree node, Void p) {
+                if (node == null) {
+                    return null;
+                }
+
+                long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+                if (start == (-1)) {
+                    return null; //synthetic tree
+                }
+                assertTrue(node.toString() + ":" + start + "/" + parentStart,
+                        parentStart <= start);
+
+                long prevParentStart = parentStart;
+
+                parentStart = start;
+
+                long end = trees.getSourcePositions().getEndPosition(cut, node);
+
+                assertTrue(node.toString() + ":" + end + "/" + parentEnd,
+                        end <= parentEnd);
+
+                long prevParentEnd = parentEnd;
+
+                parentEnd = end;
+
+                super.scan(node, p);
+
+                parentStart = prevParentStart;
+                parentEnd = prevParentEnd;
+
+                return null;
+            }
+
+            private void assertTrue(String message, boolean b) {
+                if (!b) fail(message);
+            }
+        }.scan(cut, null);
+    }
+
+    public void testCorrectWilcardPositions() throws IOException {
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { List<? extends List<? extends String>> l; } }",
+
+                Arrays.asList("List<? extends List<? extends String>> l;",
+                "List<? extends List<? extends String>>",
+                "List",
+                "? extends List<? extends String>",
+                "List<? extends String>",
+                "List",
+                "? extends String",
+                "String"));
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { List<? super List<? super String>> l; } }",
+
+                Arrays.asList("List<? super List<? super String>> l;",
+                "List<? super List<? super String>>",
+                "List",
+                "? super List<? super String>",
+                "List<? super String>",
+                "List",
+                "? super String",
+                "String"));
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { List<? super List<?>> l; } }",
+
+                Arrays.asList("List<? super List<?>> l;",
+                "List<? super List<?>>",
+                "List",
+                "? super List<?>",
+                "List<?>",
+                "List",
+                "?"));
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { " +
+                "List<? extends List<? extends List<? extends String>>> l; } }",
+
+                Arrays.asList("List<? extends List<? extends List<? extends String>>> l;",
+                "List<? extends List<? extends List<? extends String>>>",
+                "List",
+                "? extends List<? extends List<? extends String>>",
+                "List<? extends List<? extends String>>",
+                "List",
+                "? extends List<? extends String>",
+                "List<? extends String>",
+                "List",
+                "? extends String",
+                "String"));
+        performWildcardPositionsTest("package test; import java.util.List; " +
+                "class Test { private void method() { " +
+                "List<? extends List<? extends List<? extends String   >>> l; } }",
+                Arrays.asList("List<? extends List<? extends List<? extends String   >>> l;",
+                "List<? extends List<? extends List<? extends String   >>>",
+                "List",
+                "? extends List<? extends List<? extends String   >>",
+                "List<? extends List<? extends String   >>",
+                "List",
+                "? extends List<? extends String   >",
+                "List<? extends String   >",
+                "List",
+                "? extends String",
+                "String"));
+    }
+
+    public void performWildcardPositionsTest(final String code,
+            List<String> golden) throws IOException {
+
+        final List<Diagnostic<? extends JavaFileObject>> errors =
+                new LinkedList<Diagnostic<? extends JavaFileObject>>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null,
+                new DiagnosticListener<JavaFileObject>() {
+                    public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+                        errors.add(diagnostic);
+                    }
+                }, null, null, Arrays.asList(new MyFileObject(code)));
+
+        final CompilationUnitTree cut = ct.parse().iterator().next();
+        final List<String> content = new LinkedList<String>();
+        final Trees trees = Trees.instance(ct);
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void scan(Tree node, Void p) {
+                if (node == null) {
+                    return null;
+                }
+                long start = trees.getSourcePositions().getStartPosition(cut, node);
+
+                if (start == (-1)) {
+                    return null; //synthetic tree
+                }
+                long end = trees.getSourcePositions().getEndPosition(cut, node);
+                String s = code.substring((int) start, (int) end);
+                content.add(s);
+
+                return super.scan(node, p);
+            }
+        }.scan(((MethodTree) ((ClassTree) cut.getTypeDecls().get(0)).getMembers().get(0)).getBody().getStatements().get(0), null);
+
+        assertEquals("performWildcardPositionsTest",golden.toString(),
+                content.toString());
+    }
+
+    public void testStartPositionForMethodWithoutModifiers() throws IOException {
+
+        String code = "package t; class Test { <T> void t() {} }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        MethodTree mt = (MethodTree) clazz.getMembers().get(0);
+        Trees t = Trees.instance(ct);
+        int start = (int) t.getSourcePositions().getStartPosition(cut, mt);
+        int end = (int) t.getSourcePositions().getEndPosition(cut, mt);
+
+        assertEquals("testStartPositionForMethodWithoutModifiers",
+                "<T> void t() {}", code.substring(start, end));
+    }
+
+    public void testStartPositionEnumConstantInit() throws IOException {
+
+        String code = "package t; enum Test { AAA; }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+        ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
+        VariableTree enumAAA = (VariableTree) clazz.getMembers().get(0);
+        Trees t = Trees.instance(ct);
+        int start = (int) t.getSourcePositions().getStartPosition(cut,
+                enumAAA.getInitializer());
+
+        assertEquals("testStartPositionEnumConstantInit", -1, start);
+    }
+
+    public void testVariableInIfThen1() throws IOException {
+
+        String code = "package t; class Test { " +
+                "private static void t(String name) { " +
+                "if (name != null) String nn = name.trim(); } }";
+
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen1",
+                Arrays.<String>asList("compiler.err.variable.not.allowed"),
+                codes);
+    }
+
+    public void testVariableInIfThen2() throws IOException {
+
+        String code = "package t; class Test { " +
+                "private static void t(String name) { " +
+                "if (name != null) class X {} } }";
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen2",
+                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
+    }
+
+    public void testVariableInIfThen3() throws IOException {
+
+        String code = "package t; class Test { "+
+                "private static void t(String name) { " +
+                "if (name != null) abstract } }";
+        DiagnosticCollector<JavaFileObject> coll =
+                new DiagnosticCollector<JavaFileObject>();
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        ct.parse();
+
+        List<String> codes = new LinkedList<String>();
+
+        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
+            codes.add(d.getCode());
+        }
+
+        assertEquals("testVariableInIfThen3",
+                Arrays.<String>asList("compiler.err.illegal.start.of.expr"),
+                codes);
+    }
+
+    //see javac bug #6882235, NB bug #98234:
+    public void testMissingExponent() throws IOException {
+
+        String code = "\nclass Test { { System.err.println(0e); } }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+
+        assertNotNull(ct.parse().iterator().next());
+    }
+
+    public void testTryResourcePos() throws IOException {
+
+        final String code = "package t; class Test { " +
+                "{ try (java.io.InputStream in = null) { } } }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitVariable(VariableTree node, Void p) {
+                if ("in".contentEquals(node.getName())) {
+                    JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+                    System.out.println(node.getName() + "," + var.pos);
+                    assertEquals("testTryResourcePos", "in = null) { } } }",
+                            code.substring(var.pos));
+                }
+                return super.visitVariable(node, p);
+            }
+        }.scan(cut, null);
+    }
+
+    public void testVarPos() throws IOException {
+
+        final String code = "package t; class Test { " +
+                "{ java.io.InputStream in = null; } }";
+
+        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
+                null, Arrays.asList(new MyFileObject(code)));
+        CompilationUnitTree cut = ct.parse().iterator().next();
+
+        new TreeScanner<Void, Void>() {
+
+            @Override
+            public Void visitVariable(VariableTree node, Void p) {
+                if ("in".contentEquals(node.getName())) {
+                    JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+                    assertEquals("testVarPos","in = null; } }",
+                            code.substring(var.pos));
+                }
+                return super.visitVariable(node, p);
+            }
+        }.scan(cut, null);
+    }
+
+    void testsNotWorking() throws IOException {
+
+        // Fails with nb-javac, needs further investigation
+        testPositionBrokenSource126732a();
+        testPositionBrokenSource126732b();
+
+        // Fails, these tests yet to be addressed
+        testVariableInIfThen1();
+        testVariableInIfThen2();
+        testPositionForEnumModifiers();
+        testStartPositionEnumConstantInit();
+    }
+    void testPositions() throws IOException {
+        testPositionsSane();
+        testCorrectWilcardPositions();
+        testPositionAnnotationNoPackage187551();
+        testPositionForSuperConstructorCalls();
+        testPreferredPositionForBinaryOp();
+        testStartPositionForMethodWithoutModifiers();
+        testVarPos();
+        testVariableInIfThen3();
+        testTryResourcePos();
+    }
+
+    public static void main(String... args) throws IOException {
+        JavacParserTest jpt = new JavacParserTest("JavacParserTest");
+        jpt.testPositions();
+        System.out.println("PASS");
+    }
+}
+
+abstract class TestCase {
+
+    void assertEquals(String message, int i, int pos) {
+        if (i != pos) {
+            fail(message);
+        }
+    }
+
+    void assertFalse(String message, boolean empty) {
+        throw new UnsupportedOperationException("Not yet implemented");
+    }
+
+    void assertEquals(String message, int i, long l) {
+        if (i != l) {
+            fail(message + ":" + i + ":" + l);
+        }
+    }
+
+    void assertEquals(String message, Object o1, Object o2) {
+        System.out.println(o1);
+        System.out.println(o2);
+        if (o1 != null && o2 != null && !o1.equals(o2)) {
+            fail(message);
+        }
+        if (o1 == null && o2 != null) {
+            fail(message);
+        }
+    }
+
+    void assertNotNull(Object o) {
+        if (o == null) {
+            fail();
+        }
+    }
+
+    void fail() {
+        fail("test failed");
+    }
+
+    void fail(String message) {
+        throw new RuntimeException(message);
+    }
+}
--- a/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/processing/errors/TestOptionSyntaxErrors.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, 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
@@ -27,14 +27,14 @@
  * @summary Test that annotation processor options with illegal syntax are rejected
  * @author  Joseph D. Darcy
  * @library ../../lib
- * @build JavacTestingAbstractProcessor
+ * @build JavacTestingAbstractProcessor CompileFail
  * @compile TestOptionSyntaxErrors.java
- * @compile/fail -A TestOptionSyntaxErrors.java
- * @compile/fail -A8adOption TestOptionSyntaxErrors.java
- * @compile/fail -A8adOption=1worseOption TestOptionSyntaxErrors.java
- * @compile/fail -processor TestOptionSyntaxErrors -proc:only -A TestOptionSyntaxErrors.java
- * @compile/fail -processor TestOptionSyntaxErrors -proc:only -A8adOption TestOptionSyntaxErrors.java
- * @compile/fail -processor TestOptionSyntaxErrors -proc:only -A8adOption=1worseOption TestOptionSyntaxErrors.java
+ * @run main CompileFail CMDERR -A TestOptionSyntaxErrors.java
+ * @run main CompileFail CMDERR -A8adOption TestOptionSyntaxErrors.java
+ * @run main CompileFail CMDERR -A8adOption=1worseOption TestOptionSyntaxErrors.java
+ * @run main CompileFail CMDERR -processor TestOptionSyntaxErrors -proc:only -A TestOptionSyntaxErrors.java
+ * @run main CompileFail CMDERR -processor TestOptionSyntaxErrors -proc:only -A8adOption TestOptionSyntaxErrors.java
+ * @run main CompileFail CMDERR -processor TestOptionSyntaxErrors -proc:only -A8adOption=1worseOption TestOptionSyntaxErrors.java
  */
 
 import java.util.Set;
--- a/test/tools/javac/processing/errors/TestReturnCode.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/processing/errors/TestReturnCode.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2010, 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
@@ -27,25 +27,25 @@
  * @summary Test that an erroneous return code results from raising an error.
  * @author  Joseph D. Darcy
  * @library ../../lib
- * @build JavacTestingAbstractProcessor
+ * @build JavacTestingAbstractProcessor CompileFail
  * @compile TestReturnCode.java
  *
- * @compile      -processor TestReturnCode -proc:only                                                                   Foo.java
- * @compile/fail -processor TestReturnCode -proc:only                                                    -AErrorOnFirst Foo.java
- * @compile/fail -processor TestReturnCode -proc:only                                      -AErrorOnLast                Foo.java
- * @compile/fail -processor TestReturnCode -proc:only                                      -AErrorOnLast -AErrorOnFirst Foo.java
- * @compile/fail -processor TestReturnCode -proc:only                   -AExceptionOnFirst                              Foo.java
- * @compile/fail -processor TestReturnCode -proc:only                   -AExceptionOnFirst               -AErrorOnFirst Foo.java
- * @compile/fail -processor TestReturnCode -proc:only                   -AExceptionOnFirst -AErrorOnLast                Foo.java
- * @compile/fail -processor TestReturnCode -proc:only                   -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast                                                 Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast                                  -AErrorOnFirst Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast                    -AErrorOnLast                Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast                    -AErrorOnLast -AErrorOnFirst Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst                              Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst               -AErrorOnFirst Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast                Foo.java
- * @compile/fail -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java
+ * @compile                     -processor TestReturnCode -proc:only                                                                   Foo.java
+ * @run main CompileFail ERROR  -processor TestReturnCode -proc:only                                                    -AErrorOnFirst Foo.java
+ * @run main CompileFail ERROR  -processor TestReturnCode -proc:only                                      -AErrorOnLast                Foo.java
+ * @run main CompileFail ERROR  -processor TestReturnCode -proc:only                                      -AErrorOnLast -AErrorOnFirst Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only                   -AExceptionOnFirst                              Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only                   -AExceptionOnFirst               -AErrorOnFirst Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only                   -AExceptionOnFirst -AErrorOnLast                Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only                   -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast                                                 Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast                                  -AErrorOnFirst Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast                    -AErrorOnLast                Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast                    -AErrorOnLast -AErrorOnFirst Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst                              Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst               -AErrorOnFirst Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast                Foo.java
+ * @run main CompileFail SYSERR -processor TestReturnCode -proc:only -AExceptionOnLast -AExceptionOnFirst -AErrorOnLast -AErrorOnFirst Foo.java
  */
 
 import java.util.Set;
--- a/test/tools/javac/processing/errors/TestSuppression.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/processing/errors/TestSuppression.java	Sun Feb 26 16:05:18 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,6 +35,7 @@
 import javax.tools.*;
 
 import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.ClientCodeWrapper;
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.util.JCDiagnostic;
 
@@ -171,7 +172,7 @@
 
         public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
             System.err.println((++total) + ": "
-                    + "resolveError:" + isResolveError((JCDiagnostic) diagnostic) + "\n"
+                    + "resolveError:" + isResolveError(unwrap(diagnostic)) + "\n"
                     + diagnostic);
             Diagnostic.Kind dk = diagnostic.getKind();
             Integer c = counts.get(dk);
@@ -181,6 +182,14 @@
         private static boolean isResolveError(JCDiagnostic d) {
             return d.isFlagSet(RESOLVE_ERROR);
         }
+
+        private JCDiagnostic unwrap(Diagnostic<? extends JavaFileObject> diagnostic) {
+            if (diagnostic instanceof JCDiagnostic)
+                return (JCDiagnostic) diagnostic;
+            if (diagnostic instanceof ClientCodeWrapper.DiagnosticSourceUnwrapper)
+                return ((ClientCodeWrapper.DiagnosticSourceUnwrapper)diagnostic).d;
+            throw new IllegalArgumentException();
+        }
     }
 
     @SupportedAnnotationTypes("*")
--- a/test/tools/javac/warnings/Serial.java	Thu Jul 14 21:53:20 2011 -0400
+++ b/test/tools/javac/warnings/Serial.java	Sun Feb 26 16:05:18 2012 -0800
@@ -29,7 +29,6 @@
  * @compile -Xlint:all Serial.java
  * @compile -Werror Serial.java
  * @compile/fail -Werror -Xlint:serial Serial.java
- * @compile/fail -Werror -Xlint:all,-path T4994049/ Serial.java
  */
 
 import java.io.Serializable;