changeset 1317:7450073e2e6f

Merge jdk8-b44
author andrew
date Thu, 02 Aug 2012 17:00:14 +0100
parents 24540bbb4135 (current diff) e111e4587cca (diff)
children 45a1817f956b
files .hgtags src/share/classes/com/sun/tools/javac/parser/EndPosTable.java test/tools/javac/diags/examples/FullInstSig.java test/tools/javac/diags/examples/InvalidInferredTypes.java test/tools/javac/diags/examples/UndeterminedType1.java
diffstat 66 files changed, 1752 insertions(+), 1201 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Tue May 29 00:27:58 2012 +0100
+++ b/.hgtags	Thu Aug 02 17:00:14 2012 +0100
@@ -165,3 +165,7 @@
 1f224f160aa852c9541380735a27a3439dfb7217 jdk8-b38
 a9f547c218d957306dfc0cdd710be041bb62a555 jdk8-b39
 86e0dad6aadf626bf5755f503aee2d0da525d9d5 jdk8-b40
+179fa85aeefab338cccf1cbe8b494c59bc5df122 jdk8-b41
+02c5a3575539e737a1855b31287654e843edd6da jdk8-b42
+f8c64d835b2806293b8e924b44f0e32b20657ed3 jdk8-b43
+59cbead12ff46dbb397120bd26635bcd7d41ff21 jdk8-b44
--- a/makefiles/Makefile	Tue May 29 00:27:58 2012 +0100
+++ b/makefiles/Makefile	Thu Aug 02 17:00:14 2012 +0100
@@ -23,12 +23,13 @@
 # questions.
 #
 
+# This must be the first rule
+default: all
+
 include $(SPEC)
 include MakeBase.gmk
 include JavaCompilation.gmk
 
-default: all
-
 # The BOOT_JAVAC setup uses the bootdir compiler to compile the tools
 # and the bootstrap javac, to be run by the bootdir jvm.
 $(eval $(call SetupJavaCompiler,BOOT_JAVAC,\
@@ -184,8 +185,7 @@
 			SETUP:=GENERATE_NEWBYTECODE,\
 			SRCS:=$(LANGTOOLS_OUTPUTDIR)/classes,\
 			SUFFIXES:=.class $(RESOURCE_SUFFIXES),\
-			JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar,\
-			HEADERS:=$(LANGTOOLS_OUTPUTDIR)/gensrc_headers))
+			JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar))
 
                 $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE,\
 			SRC:=$(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc,\
--- a/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/api/JavacTrees.java	Thu Aug 02 17:00:14 2012 +0100
@@ -60,7 +60,7 @@
 import com.sun.tools.javac.comp.MemberEnter;
 import com.sun.tools.javac.comp.Resolve;
 import com.sun.tools.javac.model.JavacElements;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.processing.JavacProcessingEnvironment;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.*;
@@ -240,10 +240,11 @@
 
     public String getDocComment(TreePath path) {
         CompilationUnitTree t = path.getCompilationUnit();
-        if (t instanceof JCTree.JCCompilationUnit) {
+        Tree leaf = path.getLeaf();
+        if (t instanceof JCTree.JCCompilationUnit && leaf instanceof JCTree) {
             JCCompilationUnit cu = (JCCompilationUnit) t;
             if (cu.docComments != null) {
-                return cu.docComments.get(path.getLeaf());
+                return cu.docComments.getCommentText((JCTree) leaf);
             }
         }
         return null;
--- a/src/share/classes/com/sun/tools/javac/code/Type.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Aug 02 17:00:14 2012 +0100
@@ -54,7 +54,7 @@
  *  package types (tag: PACKAGE, class: PackageType),
  *  type variables (tag: TYPEVAR, class: TypeVar),
  *  type arguments (tag: WILDCARD, class: WildcardType),
- *  polymorphic types (tag: FORALL, class: ForAll),
+ *  generic method types (tag: FORALL, class: ForAll),
  *  the error type (tag: ERROR, class: ErrorType).
  *  </pre>
  *
@@ -1108,11 +1108,16 @@
         public boolean isErroneous() { return qtype.isErroneous(); }
     }
 
+    /**
+     * The type of a generic method type. It consists of a method type and
+     * a list of method type-parameters that are used within the method
+     * type.
+     */
     public static class ForAll extends DelegatedType implements ExecutableType {
         public List<Type> tvars;
 
         public ForAll(List<Type> tvars, Type qtype) {
-            super(FORALL, qtype);
+            super(FORALL, (MethodType)qtype);
             this.tvars = tvars;
         }
 
@@ -1131,34 +1136,6 @@
             return qtype.isErroneous();
         }
 
-        /**
-         * Replaces this ForAll's typevars with a set of concrete Java types
-         * and returns the instantiated generic type. Subclasses should override
-         * in order to check that the list of types is a valid instantiation
-         * of the ForAll's typevars.
-         *
-         * @param actuals list of actual types
-         * @param types types instance
-         * @return qtype where all occurrences of tvars are replaced
-         * by types in actuals
-         */
-        public Type inst(List<Type> actuals, Types types) {
-            return types.subst(qtype, tvars, actuals);
-        }
-
-        /**
-         * Get the type-constraints of a given kind for a given type-variable of
-         * this ForAll type. Subclasses should override in order to return more
-         * accurate sets of constraints.
-         *
-         * @param tv the type-variable for which the constraint is to be retrieved
-         * @param ck the constraint kind to be retrieved
-         * @return the list of types specified by the selected constraint
-         */
-        public List<Type> undetvars() {
-            return List.nil();
-        }
-
         public Type map(Mapping f) {
             return f.apply(qtype);
         }
@@ -1168,7 +1145,7 @@
         }
 
         public MethodType asMethodType() {
-            return qtype.asMethodType();
+            return (MethodType)qtype;
         }
 
         public void complete() {
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Aug 02 17:00:14 2012 +0100
@@ -702,6 +702,13 @@
         return t;
     }
 
+    Type attribIdentAsEnumType(Env<AttrContext> env, JCIdent id) {
+        Assert.check((env.enclClass.sym.flags() & ENUM) != 0);
+        id.type = env.info.scope.owner.type;
+        id.sym = env.info.scope.owner;
+        return id.type;
+    }
+
     public void visitClassDef(JCClassDecl tree) {
         // Local classes have not been entered yet, so we need to do it now:
         if ((env.info.scope.owner.kind & (VAR | MTH)) != 0)
@@ -1529,7 +1536,7 @@
 
                     // ...and check that it is legal in the current context.
                     // (this will also set the tree's type)
-                    Type mpt = newMethTemplate(argtypes, typeargtypes);
+                    Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
                     checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt),
                             tree.varargsElement != null);
                 }
@@ -1545,7 +1552,7 @@
             // ... and attribute the method using as a prototype a methodtype
             // whose formal argument types is exactly the list of actual
             // arguments (this will also set the method symbol).
-            Type mpt = newMethTemplate(argtypes, typeargtypes);
+            Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes);
             localEnv.info.varArgs = false;
             Type mtype = attribExpr(tree.meth, localEnv, mpt);
 
@@ -1608,8 +1615,8 @@
 
         /** Obtain a method type with given argument types.
          */
-        Type newMethTemplate(List<Type> argtypes, List<Type> typeargtypes) {
-            MethodType mt = new MethodType(argtypes, null, null, syms.methodClass);
+        Type newMethodTemplate(Type restype, List<Type> argtypes, List<Type> typeargtypes) {
+            MethodType mt = new MethodType(argtypes, restype, null, syms.methodClass);
             return (typeargtypes == null) ? mt : (Type)new ForAll(typeargtypes, mt);
         }
 
@@ -1657,7 +1664,10 @@
 
         // Attribute clazz expression and store
         // symbol + type back into the attributed tree.
-        Type clazztype = attribType(clazz, env);
+        Type clazztype = TreeInfo.isEnumInit(env.tree) ?
+            attribIdentAsEnumType(env, (JCIdent)clazz) :
+            attribType(clazz, env);
+
         clazztype = chk.checkDiamond(tree, clazztype);
         chk.validate(clazz, localEnv);
         if (tree.encl != null) {
@@ -1883,25 +1893,23 @@
                     typeargtypes);
 
         if (constructor.kind == MTH) {
-            clazztype = checkMethod(site,
-                    constructor,
-                    localEnv,
-                    tree.args,
-                    argtypes,
-                    typeargtypes,
-                    localEnv.info.varArgs).getReturnType();
-        } else {
-            clazztype = syms.errType;
-        }
-
-        if (clazztype.tag == FORALL && !resultInfo.pt.isErroneous()) {
             try {
-                clazztype = resultInfo.checkContext.rawInstantiatePoly((ForAll)clazztype, pt(), Warner.noWarnings);
-            } catch (Infer.InferenceException ex) {
+                clazztype = rawCheckMethod(site,
+                        constructor,
+                        resultInfo,
+                        localEnv,
+                        tree.args,
+                        argtypes,
+                        typeargtypes,
+                        localEnv.info.varArgs).getReturnType();
+            } catch (Resolve.InapplicableMethodException ex) {
                 //an error occurred while inferring uninstantiated type-variables
                 resultInfo.checkContext.report(tree.clazz.pos(), clazztype, resultInfo.pt,
                         diags.fragment("cant.apply.diamond.1", diags.fragment("diamond", clazztype.tsym), ex.diagnostic));
+                clazztype = syms.errType;
             }
+        } else {
+            clazztype = syms.errType;
         }
 
         return chk.checkClassType(tree.clazz.pos(), clazztype, true);
@@ -2255,15 +2263,6 @@
             sitesym != null &&
             sitesym.name == names._super;
 
-        // If selected expression is polymorphic, strip
-        // type parameters and remember in env.info.tvars, so that
-        // they can be added later (in Attr.checkId and Infer.instantiateMethod).
-        if (tree.selected.type.tag == FORALL) {
-            ForAll pstype = (ForAll)tree.selected.type;
-            env.info.tvars = pstype.tvars;
-            site = tree.selected.type = pstype.qtype;
-        }
-
         // Determine the symbol represented by the selection.
         env.info.varArgs = false;
         Symbol sym = selectSym(tree, sitesym, site, env, resultInfo);
@@ -2347,7 +2346,6 @@
 
         env.info.selectSuper = selectSuperPrev;
         result = checkId(tree, site, sym, env, resultInfo, varArgs);
-        env.info.tvars = List.nil();
     }
     //where
         /** Determine symbol referenced by a Select expression,
@@ -2530,16 +2528,6 @@
                     ? types.memberType(site, sym)
                     : sym.type;
 
-                if (env.info.tvars.nonEmpty()) {
-                    Type owntype1 = new ForAll(env.info.tvars, owntype);
-                    for (List<Type> l = env.info.tvars; l.nonEmpty(); l = l.tail)
-                        if (!owntype.contains(l.head)) {
-                            log.error(tree.pos(), "undetermined.type", owntype1);
-                            owntype1 = types.createErrorType(owntype1);
-                        }
-                    owntype = owntype1;
-                }
-
                 // If the variable is a constant, record constant value in
                 // computed type.
                 if (v.getConstValue() != null && isStaticReference(tree))
@@ -2551,9 +2539,10 @@
                 break;
             case MTH: {
                 JCMethodInvocation app = (JCMethodInvocation)env.tree;
-                owntype = checkMethod(site, sym, env, app.args,
-                                      resultInfo.pt.getParameterTypes(), resultInfo.pt.getTypeArguments(),
-                                      env.info.varArgs);
+                owntype = checkMethod(site, sym,
+                        new ResultInfo(VAL, resultInfo.pt.getReturnType(), resultInfo.checkContext),
+                        env, app.args, resultInfo.pt.getParameterTypes(),
+                        resultInfo.pt.getTypeArguments(), env.info.varArgs);
                 break;
             }
             case PCK: case ERR:
@@ -2692,6 +2681,33 @@
      **/
     public Type checkMethod(Type site,
                             Symbol sym,
+                            ResultInfo resultInfo,
+                            Env<AttrContext> env,
+                            final List<JCExpression> argtrees,
+                            List<Type> argtypes,
+                            List<Type> typeargtypes,
+                            boolean useVarargs) {
+        try {
+            return rawCheckMethod(site, sym, resultInfo, env, argtrees, argtypes, typeargtypes, useVarargs);
+        } catch (Resolve.InapplicableMethodException ex) {
+            String key = ex.getDiagnostic() == null ?
+                    "cant.apply.symbol" :
+                    "cant.apply.symbol.1";
+            log.error(env.tree.pos, key,
+                      Kinds.kindName(sym),
+                      sym.name == names.init ? sym.owner.name : sym.name,
+                      rs.methodArguments(sym.type.getParameterTypes()),
+                      rs.methodArguments(argtypes),
+                      Kinds.kindName(sym.owner),
+                      sym.owner.type,
+                      ex.getDiagnostic());
+            return types.createErrorType(site);
+        }
+    }
+
+    private Type rawCheckMethod(Type site,
+                            Symbol sym,
+                            ResultInfo resultInfo,
                             Env<AttrContext> env,
                             final List<JCExpression> argtrees,
                             List<Type> argtypes,
@@ -2717,32 +2733,19 @@
         // Resolve.instantiate from the symbol's type as well as
         // any type arguments and value arguments.
         noteWarner.clear();
-        Type owntype = rs.instantiate(env,
-                                      site,
-                                      sym,
-                                      argtypes,
-                                      typeargtypes,
-                                      true,
-                                      useVarargs,
-                                      noteWarner);
+        Type owntype = rs.rawInstantiate(env,
+                                          site,
+                                          sym,
+                                          resultInfo,
+                                          argtypes,
+                                          typeargtypes,
+                                          true,
+                                          useVarargs,
+                                          noteWarner);
 
         boolean unchecked = noteWarner.hasNonSilentLint(LintCategory.UNCHECKED);
 
-        // If this fails, something went wrong; we should not have
-        // found the identifier in the first place.
-        if (owntype == null) {
-            if (!pt().isErroneous())
-                log.error(env.tree.pos(),
-                           "internal.error.cant.instantiate",
-                           sym, site,
-                          Type.toString(pt().getParameterTypes()));
-            owntype = types.createErrorType(site);
-            return types.createErrorType(site);
-        } else if (owntype.getReturnType().tag == FORALL && !unchecked) {
-            return owntype;
-        } else {
-            return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs, unchecked);
-        }
+        return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs, unchecked);
     }
 
     /**
@@ -2755,7 +2758,7 @@
                             List<Type> argtypes,
                             List<Type> typeargtypes,
                             boolean useVarargs) {
-        Type owntype = checkMethod(site, sym, env, argtrees, argtypes, typeargtypes, useVarargs);
+        Type owntype = checkMethod(site, sym, new ResultInfo(VAL, syms.voidType), env, argtrees, argtypes, typeargtypes, useVarargs);
         chk.checkType(env.tree.pos(), owntype.getReturnType(), syms.voidType);
         return owntype;
     }
--- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java	Thu Aug 02 17:00:14 2012 +0100
@@ -58,10 +58,6 @@
      */
     boolean varArgs = false;
 
-    /** A list of type variables that are all-quantifed in current context.
-     */
-    List<Type> tvars = List.nil();
-
     /** A record of the lint/SuppressWarnings currently in effect
      */
     Lint lint;
@@ -80,7 +76,6 @@
         info.isSelfCall = isSelfCall;
         info.selectSuper = selectSuper;
         info.varArgs = varArgs;
-        info.tvars = tvars;
         info.lint = lint;
         info.enclVar = enclVar;
         return info;
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Check.java	Thu Aug 02 17:00:14 2012 +0100
@@ -424,10 +424,6 @@
          */
         boolean compatible(Type found, Type req, Warner warn);
         /**
-         * Instantiate a ForAll type against a given target type 'req' in given context
-         */
-        Type rawInstantiatePoly(ForAll found, Type req, Warner warn);
-        /**
          * Report a check error
          */
         void report(DiagnosticPosition pos, Type found, Type req, JCDiagnostic details);
@@ -454,10 +450,6 @@
             return enclosingContext.compatible(found, req, warn);
         }
 
-        public Type rawInstantiatePoly(ForAll found, Type req, Warner warn) {
-            return enclosingContext.rawInstantiatePoly(found, req, warn);
-        }
-
         public void report(DiagnosticPosition pos, Type found, Type req, JCDiagnostic details) {
             enclosingContext.report(pos, found, req, details);
         }
@@ -482,12 +474,6 @@
             return types.isAssignable(found, req, warn);
         }
 
-        public Type rawInstantiatePoly(ForAll found, Type req, Warner warn) {
-            if (req.tag == NONE)
-                req = found.qtype.tag <= VOID ? found.qtype : syms.objectType;
-            return infer.instantiateExpr(found, req, warn);
-        }
-
         public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) {
             return convertWarner(pos, found, req);
         }
@@ -506,11 +492,6 @@
     Type checkType(final DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) {
         if (req.tag == ERROR)
             return req;
-        if (found.tag == FORALL) {
-            ForAll fa = (ForAll)found;
-            Type owntype = instantiatePoly(pos, checkContext, fa, req, checkContext.checkWarner(pos, found, req));
-            return checkType(pos, owntype, req, checkContext);
-        }
         if (req.tag == NONE)
             return found;
         if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) {
@@ -525,32 +506,6 @@
         }
     }
 
-    /** Instantiate polymorphic type to some prototype, unless
-     *  prototype is `anyPoly' in which case polymorphic type
-     *  is returned unchanged.
-     */
-    Type instantiatePoly(DiagnosticPosition pos, CheckContext checkContext, ForAll t, Type pt, Warner warn) throws Infer.NoInstanceException {
-        try {
-            return checkContext.rawInstantiatePoly(t, pt, warn);
-        } catch (final Infer.NoInstanceException ex) {
-            JCDiagnostic d = ex.getDiagnostic();
-            if (d != null) {
-                if (ex.isAmbiguous) {
-                    d = diags.fragment("undetermined.type", t, d);
-                }
-            }
-            checkContext.report(pos, t, pt, d);
-            return types.createErrorType(pt);
-        } catch (Infer.InvalidInstanceException ex) {
-            JCDiagnostic d = ex.getDiagnostic();
-            if (d != null) {
-                d = diags.fragment("invalid.inferred.types", t.tvars, d);
-            }
-            checkContext.report(pos, t, pt, d);
-            return types.createErrorType(pt);
-        }
-    }
-
     /** Check that a given type can be cast to a given target type.
      *  Return the result of the cast.
      *  @param pos        Position to be used for error reporting.
@@ -561,10 +516,7 @@
         return checkCastable(pos, found, req, basicHandler);
     }
     Type checkCastable(DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) {
-        if (found.tag == FORALL) {
-            instantiatePoly(pos, basicHandler, (ForAll) found, req, castWarner(pos, found, req));
-            return req;
-        } else if (types.isCastable(found, req, castWarner(pos, found, req))) {
+        if (types.isCastable(found, req, castWarner(pos, found, req))) {
             return req;
         } else {
             checkContext.report(pos, found, req, diags.fragment("inconvertible.types", found, req));
--- a/src/share/classes/com/sun/tools/javac/comp/Enter.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Enter.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -312,7 +312,7 @@
                                 tree.packge);
                     if (addEnv || (tree0.packageAnnotations.isEmpty() &&
                                    tree.docComments != null &&
-                                   tree.docComments.get(tree) != null)) {
+                                   tree.docComments.hasComment(tree))) {
                         typeEnvs.put(tree.packge, topEnv);
                     }
                 }
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Aug 02 17:00:14 2012 +0100
@@ -214,16 +214,23 @@
      *  If no instantiation exists, or if several incomparable
      *  best instantiations exist throw a NoInstanceException.
      */
-    public Type instantiateExpr(ForAll that,
-                                Type to,
+    public List<Type> instantiateUninferred(DiagnosticPosition pos,
+                                List<Type> undetvars,
+                                List<Type> tvars,
+                                MethodType mtype,
+                                Attr.ResultInfo resultInfo,
                                 Warner warn) throws InferenceException {
-        List<Type> undetvars = that.undetvars();
-        Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
+        Type to = resultInfo.pt;
+        if (to.tag == NONE) {
+            to = mtype.getReturnType().tag <= VOID ?
+                    mtype.getReturnType() : syms.objectType;
+        }
+        Type qtype1 = types.subst(mtype.getReturnType(), tvars, undetvars);
         if (!types.isSubtype(qtype1,
                 qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) {
             throw unambiguousNoInstanceException
                 .setMessage("infer.no.conforming.instance.exists",
-                            that.tvars, that.qtype, to);
+                            tvars, mtype.getReturnType(), to);
         }
 
         List<Type> insttypes;
@@ -232,32 +239,32 @@
             insttypes = List.nil();
             for (Type t : undetvars) {
                 UndetVar uv = (UndetVar)t;
-                if (uv.inst == null && (uv.eq.nonEmpty() || !Type.containsAny(uv.hibounds, that.tvars))) {
+                if (uv.inst == null && (uv.eq.nonEmpty() || !Type.containsAny(uv.hibounds, tvars))) {
                     maximizeInst((UndetVar)t, warn);
                     stuck = false;
                 }
                 insttypes = insttypes.append(uv.inst == null ? uv.qtype : uv.inst);
             }
-            if (!Type.containsAny(insttypes, that.tvars)) {
+            if (!Type.containsAny(insttypes, tvars)) {
                 //all variables have been instantiated - exit
                 break;
             } else if (stuck) {
                 //some variables could not be instantiated because of cycles in
                 //upper bounds - provide a (possibly recursive) default instantiation
                 insttypes = types.subst(insttypes,
-                    that.tvars,
-                    instantiateAsUninferredVars(undetvars, that.tvars));
+                    tvars,
+                    instantiateAsUninferredVars(undetvars, tvars));
                 break;
             } else {
                 //some variables have been instantiated - replace newly instantiated
                 //variables in remaining upper bounds and continue
                 for (Type t : undetvars) {
                     UndetVar uv = (UndetVar)t;
-                    uv.hibounds = types.subst(uv.hibounds, that.tvars, insttypes);
+                    uv.hibounds = types.subst(uv.hibounds, tvars, insttypes);
                 }
             }
         }
-        return that.inst(insttypes, types);
+        return insttypes;
     }
 
     /**
@@ -296,18 +303,19 @@
     /** Instantiate method type `mt' by finding instantiations of
      *  `tvars' so that method can be applied to `argtypes'.
      */
-    public Type instantiateMethod(final Env<AttrContext> env,
+    public Type instantiateMethod(Env<AttrContext> env,
                                   List<Type> tvars,
                                   MethodType mt,
-                                  final Symbol msym,
-                                  final List<Type> argtypes,
-                                  final boolean allowBoxing,
-                                  final boolean useVarargs,
-                                  final Warner warn) throws InferenceException {
+                                  Attr.ResultInfo resultInfo,
+                                  Symbol msym,
+                                  List<Type> argtypes,
+                                  boolean allowBoxing,
+                                  boolean useVarargs,
+                                  Warner warn) throws InferenceException {
         //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
-        final List<Type> undetvars =  makeUndetvars(tvars);
+        List<Type> undetvars =  makeUndetvars(tvars);
 
-        final List<Type> capturedArgs =
+        List<Type> capturedArgs =
                 rs.checkRawArgumentsAcceptable(env, undetvars, argtypes, mt.getParameterTypes(),
                     allowBoxing, useVarargs, warn, new InferenceCheckHandler(undetvars));
 
@@ -344,38 +352,23 @@
 
         mt = (MethodType)types.subst(mt, tvars, insttypes.toList());
 
-        if (!restvars.isEmpty()) {
-            // if there are uninstantiated variables,
-            // quantify result type with them
-            final List<Type> inferredTypes = insttypes.toList();
-            final List<Type> all_tvars = tvars; //this is the wrong tvars
-            return new UninferredMethodType(env.tree.pos(), msym, mt, restvars.toList()) {
-                @Override
-                List<Type> undetvars() {
-                    return restundet.toList();
-                }
-                @Override
-                void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
-                    Type owntype = new MethodType(types.subst(getParameterTypes(), tvars, inferred),
-                                       restype,
-                                       types.subst(getThrownTypes(), tvars, inferred),
-                                       qtype.tsym);
-                    // check that actuals conform to inferred formals
-                    warn.clear();
-                    checkArgumentsAcceptable(env, capturedArgs, owntype.getParameterTypes(), allowBoxing, useVarargs, warn);
-                    // check that inferred bounds conform to their bounds
-                    checkWithinBounds(all_tvars, undetvars,
-                           types.subst(inferredTypes, tvars, inferred), warn);
-                    qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs, warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED));
-                }
-            };
+        if (!restvars.isEmpty() && resultInfo != null) {
+            List<Type> restInferred =
+                    instantiateUninferred(env.tree.pos(), restundet.toList(), restvars.toList(), mt, resultInfo, warn);
+            checkWithinBounds(tvars, undetvars,
+                           types.subst(insttypes.toList(), restvars.toList(), restInferred), warn);
+            mt = (MethodType)types.subst(mt, restvars.toList(), restInferred);
+            if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
+                log.note(env.tree.pos, "deferred.method.inst", msym, mt, resultInfo.pt);
+            }
         }
-        else {
+
+        if (restvars.isEmpty() || resultInfo != null) {
             // check that actuals conform to inferred formals
             checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn);
-            // return instantiated version of method type
-            return mt;
         }
+        // return instantiated version of method type
+        return mt;
     }
     //where
 
@@ -404,60 +397,6 @@
             }
         }
 
-        /**
-         * A delegated type representing a partially uninferred method type.
-         * The return type of a partially uninferred method type is a ForAll
-         * type - when the return type is instantiated (see Infer.instantiateExpr)
-         * the underlying method type is also updated.
-         */
-        abstract class UninferredMethodType extends DelegatedType {
-
-            final List<Type> tvars;
-            final Symbol msym;
-            final DiagnosticPosition pos;
-
-            public UninferredMethodType(DiagnosticPosition pos, Symbol msym, MethodType mtype, List<Type> tvars) {
-                super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym));
-                this.tvars = tvars;
-                this.msym = msym;
-                this.pos = pos;
-                asMethodType().restype = new UninferredReturnType(tvars, mtype.restype);
-            }
-
-            @Override
-            public MethodType asMethodType() {
-                return qtype.asMethodType();
-            }
-
-            @Override
-            public Type map(Mapping f) {
-                return qtype.map(f);
-            }
-
-            abstract void instantiateReturnType(Type restype, List<Type> inferred, Types types);
-
-            abstract List<Type> undetvars();
-
-            class UninferredReturnType extends ForAll {
-                public UninferredReturnType(List<Type> tvars, Type restype) {
-                    super(tvars, restype);
-                }
-                @Override
-                public Type inst(List<Type> actuals, Types types) {
-                    Type newRestype = super.inst(actuals, types);
-                    instantiateReturnType(newRestype, actuals, types);
-                    if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
-                        log.note(pos, "deferred.method.inst", msym, UninferredMethodType.this.qtype, newRestype);
-                    }
-                    return UninferredMethodType.this.qtype.getReturnType();
-                }
-                @Override
-                public List<Type> undetvars() {
-                    return UninferredMethodType.this.undetvars();
-                }
-            }
-        }
-
         private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals,
                 boolean allowBoxing, boolean useVarargs, Warner warn) {
             try {
--- a/src/share/classes/com/sun/tools/javac/comp/Lower.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -40,7 +40,7 @@
 import com.sun.tools.javac.code.Type.*;
 
 import com.sun.tools.javac.jvm.Target;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.BLOCK;
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Thu Aug 02 17:00:14 2012 +0100
@@ -248,7 +248,7 @@
                                    final Name name,
                                    final Env<AttrContext> env) {
         if (tsym.kind != TYP) {
-            log.error(pos, "static.imp.only.classes.and.interfaces");
+            log.error(DiagnosticFlag.RECOVERABLE, pos, "static.imp.only.classes.and.interfaces");
             return;
         }
 
@@ -620,7 +620,11 @@
         DeferredLintHandler prevLintHandler =
                 chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos()));
         try {
-            attr.attribType(tree.vartype, localEnv);
+            if (TreeInfo.isEnumInit(tree)) {
+                attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype);
+            } else {
+                attr.attribType(tree.vartype, localEnv);
+            }
         } finally {
             chk.setDeferredLintHandler(prevLintHandler);
         }
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Thu Aug 02 17:00:14 2012 +0100
@@ -224,12 +224,8 @@
 
     JCDiagnostic getVerboseApplicableCandidateDiag(int pos, Symbol sym, Type inst) {
         JCDiagnostic subDiag = null;
-        if (inst.getReturnType().tag == FORALL) {
-            Type diagType = types.createMethodTypeWithReturn(inst.asMethodType(),
-                                                            ((ForAll)inst.getReturnType()).qtype);
-            subDiag = diags.fragment("partial.inst.sig", diagType);
-        } else if (sym.type.tag == FORALL) {
-            subDiag = diags.fragment("full.inst.sig", inst.asMethodType());
+        if (sym.type.tag == FORALL) {
+            subDiag = diags.fragment("partial.inst.sig", inst);
         }
 
         String key = subDiag == null ?
@@ -442,6 +438,7 @@
     Type rawInstantiate(Env<AttrContext> env,
                         Type site,
                         Symbol m,
+                        ResultInfo resultInfo,
                         List<Type> argtypes,
                         List<Type> typeargtypes,
                         boolean allowBoxing,
@@ -454,11 +451,7 @@
 
         // tvars is the list of formal type variables for which type arguments
         // need to inferred.
-        List<Type> tvars = null;
-        if (env.info.tvars != null) {
-            tvars = types.newInstances(env.info.tvars);
-            mt = types.subst(mt, env.info.tvars, tvars);
-        }
+        List<Type> tvars = List.nil();
         if (typeargtypes == null) typeargtypes = List.nil();
         if (mt.tag != FORALL && typeargtypes.nonEmpty()) {
             // This is not a polymorphic method, but typeargs are supplied
@@ -499,6 +492,7 @@
             return infer.instantiateMethod(env,
                                     tvars,
                                     (MethodType)mt,
+                                    resultInfo,
                                     m,
                                     argtypes,
                                     allowBoxing,
@@ -515,13 +509,14 @@
     Type instantiate(Env<AttrContext> env,
                      Type site,
                      Symbol m,
+                     ResultInfo resultInfo,
                      List<Type> argtypes,
                      List<Type> typeargtypes,
                      boolean allowBoxing,
                      boolean useVarargs,
                      Warner warn) {
         try {
-            return rawInstantiate(env, site, m, argtypes, typeargtypes,
+            return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes,
                                   allowBoxing, useVarargs, warn);
         } catch (InapplicableMethodException ex) {
             return null;
@@ -937,7 +932,7 @@
         if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
         Assert.check(sym.kind < AMBIGUOUS);
         try {
-            Type mt = rawInstantiate(env, site, sym, argtypes, typeargtypes,
+            Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes,
                                allowBoxing, useVarargs, Warner.noWarnings);
             if (!operator)
                 currentResolutionContext.addApplicableCandidate(sym, mt);
@@ -1071,7 +1066,7 @@
     private boolean signatureMoreSpecific(Env<AttrContext> env, Type site, Symbol m1, Symbol m2, boolean allowBoxing, boolean useVarargs) {
         noteWarner.clear();
         Type mtype1 = types.memberType(site, adjustVarargs(m1, m2, useVarargs));
-        Type mtype2 = instantiate(env, site, adjustVarargs(m2, m1, useVarargs),
+        Type mtype2 = instantiate(env, site, adjustVarargs(m2, m1, useVarargs), null,
                 types.lowerBoundArgtypes(mtype1), null,
                 allowBoxing, false, noteWarner);
         return mtype2 != null &&
--- a/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/file/ZipFileIndex.java	Thu Aug 02 17:00:14 2012 +0100
@@ -36,6 +36,7 @@
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Collections;
+import java.util.LinkedHashMap;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -284,7 +285,7 @@
         try {
             checkIndex();
             if (allDirs == Collections.EMPTY_SET) {
-                allDirs = new HashSet<RelativeDirectory>(directories.keySet());
+                allDirs = new java.util.LinkedHashSet<RelativeDirectory>(directories.keySet());
             }
 
             return allDirs;
@@ -572,7 +573,7 @@
 
             // Add each of the files
             if (entryCount > 0) {
-                directories = new HashMap<RelativeDirectory, DirectoryEntry>();
+                directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>();
                 ArrayList<Entry> entryList = new ArrayList<Entry>();
                 int pos = 2;
                 for (int i = 0; i < entryCount; i++) {
@@ -867,7 +868,7 @@
                 if (zipFile.lastModified() != fileStamp) {
                     ret = false;
                 } else {
-                    directories = new HashMap<RelativeDirectory, DirectoryEntry>();
+                    directories = new LinkedHashMap<RelativeDirectory, DirectoryEntry>();
                     int numDirs = raf.readInt();
                     for (int nDirs = 0; nDirs < numDirs; nDirs++) {
                         int dirNameBytesLen = raf.readInt();
--- a/src/share/classes/com/sun/tools/javac/jvm/CRTable.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/CRTable.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,7 +31,7 @@
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.tree.JCTree.*;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 
 /** This class contains the CharacterRangeTable for some method
  *  and the hashtable for mapping trees or lists of trees to their
--- a/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/jvm/Gen.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
 import com.sun.tools.javac.code.Type.*;
 import com.sun.tools.javac.jvm.Code.*;
 import com.sun.tools.javac.jvm.Items.*;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree.*;
 
 import static com.sun.tools.javac.code.Flags.*;
--- a/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/model/JavacElements.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,11 +28,14 @@
 import java.lang.annotation.Annotation;
 import java.lang.annotation.Inherited;
 import java.util.Map;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.util.Elements;
 import javax.tools.JavaFileObject;
+import static javax.lang.model.util.ElementFilter.methodsIn;
+
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.TypeTags;
@@ -47,9 +50,7 @@
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.Name;
-
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
-import static javax.lang.model.util.ElementFilter.methodsIn;
 
 /**
  * Utility methods for operating on program elements.
@@ -361,7 +362,7 @@
         JCCompilationUnit toplevel = treeTop.snd;
         if (toplevel.docComments == null)
             return null;
-        return toplevel.docComments.get(tree);
+        return toplevel.docComments.getCommentText(tree);
     }
 
     public PackageElement getPackageOf(Element e) {
--- a/src/share/classes/com/sun/tools/javac/parser/EndPosTable.java	Tue May 29 00:27:58 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * 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.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.sun.tools.javac.parser;
-
-import com.sun.tools.javac.tree.JCTree;
-
-/**
- * Specifies the methods to access a mappings of syntax trees to end positions.
- * <p><b>This is NOT part of any supported API.
- * If you write code that depends on this, you do so at your own
- * risk.  This code and its internal interfaces are subject to change
- * or deletion without notice.</b></p>
- */
-public interface EndPosTable {
-
-    /**
-     * This method will return the end position of a given tree, otherwise a
-     * Positions.NOPOS will be returned.
-     * @param tree JCTree
-     * @return position of the source tree or Positions.NOPOS for non-existent mapping
-     */
-    public int getEndPos(JCTree tree);
-
-    /**
-     * Give an old tree and a new tree, the old tree will be replaced with
-     * the new tree, the position of the new tree will be that of the old
-     * tree.
-     * not exist.
-     * @param oldtree a JCTree to be replaced
-     * @param newtree a JCTree to be replaced with
-     * @return position of the old tree or Positions.NOPOS for non-existent mapping
-     */
-    public int replaceTree(JCTree oldtree, JCTree newtree);
-}
--- a/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -571,7 +571,7 @@
                             reader.scanCommentChar();
                         } while (reader.ch != CR && reader.ch != LF && reader.bp < reader.buflen);
                         if (reader.bp < reader.buflen) {
-                            comments = addDocReader(comments, processComment(pos, reader.bp, CommentStyle.LINE));
+                            comments = addComment(comments, processComment(pos, reader.bp, CommentStyle.LINE));
                         }
                         break;
                     } else if (reader.ch == '*') {
@@ -597,7 +597,7 @@
                         }
                         if (reader.ch == '/') {
                             reader.scanChar();
-                            comments = addDocReader(comments, processComment(pos, reader.bp, style));
+                            comments = addComment(comments, processComment(pos, reader.bp, style));
                             break;
                         } else {
                             lexError(pos, "unclosed.comment");
@@ -693,10 +693,10 @@
         }
     }
     //where
-        List<Comment> addDocReader(List<Comment> docReaders, Comment docReader) {
-            return docReaders == null ?
-                    List.of(docReader) :
-                    docReaders.prepend(docReader);
+        List<Comment> addComment(List<Comment> comments, Comment comment) {
+            return comments == null ?
+                    List.of(comment) :
+                    comments.prepend(comment);
         }
 
     /** Return the position where a lexical error occurred;
@@ -780,6 +780,10 @@
             return null;
         }
 
+        public int getSourcePos(int pos) {
+            return -1;
+        }
+
         public CommentStyle getStyle() {
             return cs;
         }
--- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Aug 02 17:00:14 2012 +0100
@@ -117,7 +117,7 @@
         this.allowMethodReferences = source.allowMethodReferences() &&
                 fac.options.isSet("allowMethodReferences");
         this.keepDocComments = keepDocComments;
-        docComments = keepDocComments ? new HashMap<JCTree,String>() : null;
+        docComments = newDocCommentTable(keepDocComments);
         this.keepLineMap = keepLineMap;
         this.errorTree = F.Erroneous();
         endPosTable = newEndPosTable(keepEndPositions);
@@ -128,6 +128,11 @@
                 ? new SimpleEndPosTable()
                 : new EmptyEndPosTable();
     }
+
+    protected DocCommentTable newDocCommentTable(boolean keepDocComments) {
+        return keepDocComments ? new SimpleDocCommentTable() : null;
+    }
+
     /** Switch: Should generics be recognized?
      */
     boolean allowGenerics;
@@ -417,21 +422,21 @@
 
 /* ---------- doc comments --------- */
 
-    /** A hashtable to store all documentation comments
+    /** A table to store all documentation comments
      *  indexed by the tree nodes they refer to.
      *  defined only if option flag keepDocComment is set.
      */
-    private final Map<JCTree, String> docComments;
+    private final DocCommentTable docComments;
 
     /** Make an entry into docComments hashtable,
      *  provided flag keepDocComments is set and given doc comment is non-null.
      *  @param tree   The tree to be used as index in the hashtable
      *  @param dc     The doc comment to associate with the tree, or null.
      */
-    void attach(JCTree tree, String dc) {
+    void attach(JCTree tree, Comment dc) {
         if (keepDocComments && dc != null) {
 //          System.out.println("doc comment = ");System.out.println(dc);//DEBUG
-            docComments.put(tree, dc);
+            docComments.putComment(tree, dc);
         }
     }
 
@@ -1858,7 +1863,7 @@
             return List.of(parseStatement());
         case MONKEYS_AT:
         case FINAL: {
-            String dc = token.comment(CommentStyle.JAVADOC);
+            Comment dc = token.comment(CommentStyle.JAVADOC);
             JCModifiers mods = modifiersOpt();
             if (token.kind == INTERFACE ||
                 token.kind == CLASS ||
@@ -1875,13 +1880,13 @@
             }
         }
         case ABSTRACT: case STRICTFP: {
-            String dc = token.comment(CommentStyle.JAVADOC);
+            Comment dc = token.comment(CommentStyle.JAVADOC);
             JCModifiers mods = modifiersOpt();
             return List.of(classOrInterfaceOrEnumDeclaration(mods, dc));
         }
         case INTERFACE:
         case CLASS:
-            String dc = token.comment(CommentStyle.JAVADOC);
+            Comment dc = token.comment(CommentStyle.JAVADOC);
             return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
         case ENUM:
         case ASSERT:
@@ -2418,7 +2423,7 @@
                                                                      JCExpression type,
                                                                      Name name,
                                                                      boolean reqInit,
-                                                                     String dc,
+                                                                     Comment dc,
                                                                      T vdefs)
     {
         vdefs.append(variableDeclaratorRest(pos, mods, type, name, reqInit, dc));
@@ -2434,7 +2439,7 @@
     /** VariableDeclarator = Ident VariableDeclaratorRest
      *  ConstantDeclarator = Ident ConstantDeclaratorRest
      */
-    JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, String dc) {
+    JCVariableDecl variableDeclarator(JCModifiers mods, JCExpression type, boolean reqInit, Comment dc) {
         return variableDeclaratorRest(token.pos, mods, type, ident(), reqInit, dc);
     }
 
@@ -2445,7 +2450,7 @@
      *  @param dc       The documentation comment for the variable declarations, or null.
      */
     JCVariableDecl variableDeclaratorRest(int pos, JCModifiers mods, JCExpression type, Name name,
-                                  boolean reqInit, String dc) {
+                                  boolean reqInit, Comment dc) {
         type = bracketsOpt(type);
         JCExpression init = null;
         if (token.kind == EQ) {
@@ -2539,7 +2544,7 @@
                 seenImport = true;
                 defs.append(importDeclaration());
             } else {
-                String docComment = token.comment(CommentStyle.JAVADOC);
+                Comment docComment = token.comment(CommentStyle.JAVADOC);
                 if (firstTypeDecl && !seenImport && !seenPackage) {
                     docComment = firstToken.comment(CommentStyle.JAVADOC);
                     consumedToplevelDoc = true;
@@ -2597,7 +2602,7 @@
     /** TypeDeclaration = ClassOrInterfaceOrEnumDeclaration
      *                  | ";"
      */
-    JCTree typeDeclaration(JCModifiers mods, String docComment) {
+    JCTree typeDeclaration(JCModifiers mods, Comment docComment) {
         int pos = token.pos;
         if (mods == null && token.kind == SEMI) {
             nextToken();
@@ -2612,7 +2617,7 @@
      *  @param mods     Any modifiers starting the class or interface declaration
      *  @param dc       The documentation comment for the class, or null.
      */
-    JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, String dc) {
+    JCStatement classOrInterfaceOrEnumDeclaration(JCModifiers mods, Comment dc) {
         if (token.kind == CLASS) {
             return classDeclaration(mods, dc);
         } else if (token.kind == INTERFACE) {
@@ -2656,7 +2661,7 @@
      *  @param mods    The modifiers starting the class declaration
      *  @param dc       The documentation comment for the class, or null.
      */
-    protected JCClassDecl classDeclaration(JCModifiers mods, String dc) {
+    protected JCClassDecl classDeclaration(JCModifiers mods, Comment dc) {
         int pos = token.pos;
         accept(CLASS);
         Name name = ident();
@@ -2685,7 +2690,7 @@
      *  @param mods    The modifiers starting the interface declaration
      *  @param dc       The documentation comment for the interface, or null.
      */
-    protected JCClassDecl interfaceDeclaration(JCModifiers mods, String dc) {
+    protected JCClassDecl interfaceDeclaration(JCModifiers mods, Comment dc) {
         int pos = token.pos;
         accept(INTERFACE);
         Name name = ident();
@@ -2708,7 +2713,7 @@
      *  @param mods    The modifiers starting the enum declaration
      *  @param dc       The documentation comment for the enum, or null.
      */
-    protected JCClassDecl enumDeclaration(JCModifiers mods, String dc) {
+    protected JCClassDecl enumDeclaration(JCModifiers mods, Comment dc) {
         int pos = token.pos;
         accept(ENUM);
         Name name = ident();
@@ -2767,7 +2772,7 @@
     /** EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ]
      */
     JCTree enumeratorDeclaration(Name enumName) {
-        String dc = token.comment(CommentStyle.JAVADOC);
+        Comment dc = token.comment(CommentStyle.JAVADOC);
         int flags = Flags.PUBLIC|Flags.STATIC|Flags.FINAL|Flags.ENUM;
         if (token.deprecatedFlag()) {
             flags |= Flags.DEPRECATED;
@@ -2856,7 +2861,7 @@
             nextToken();
             return List.<JCTree>nil();
         } else {
-            String dc = token.comment(CommentStyle.JAVADOC);
+            Comment dc = token.comment(CommentStyle.JAVADOC);
             int pos = token.pos;
             JCModifiers mods = modifiersOpt();
             if (token.kind == CLASS ||
@@ -2936,7 +2941,7 @@
                               Name name,
                               List<JCTypeParameter> typarams,
                               boolean isInterface, boolean isVoid,
-                              String dc) {
+                              Comment dc) {
         List<JCVariableDecl> params = formalParameters();
         if (!isVoid) type = bracketsOpt(type);
         List<JCExpression> thrown = List.nil();
--- a/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,19 +62,54 @@
     @Override
     protected Comment processComment(int pos, int endPos, CommentStyle style) {
         char[] buf = reader.getRawCharacters(pos, endPos);
-        return new JavadocComment(new ColReader(fac, buf, buf.length), style);
+        return new JavadocComment(new DocReader(fac, buf, buf.length, pos), style);
     }
 
     /**
      * This is a specialized version of UnicodeReader that keeps track of the
-     * column position within a given character stream (used for Javadoc processing).
+     * column position within a given character stream (used for Javadoc processing),
+     * and which builds a table for mapping positions in the comment string to
+     * positions in the source file.
      */
-    static class ColReader extends UnicodeReader {
+    static class DocReader extends UnicodeReader {
 
          int col;
+         int startPos;
 
-         ColReader(ScannerFactory fac, char[] input, int inputLength) {
+         /**
+          * A buffer for building a table for mapping positions in {@link #sbuf}
+          * to positions in the source buffer.
+          *
+          * The array is organized as a series of pairs of integers: the first
+          * number in each pair specifies a position in the comment text,
+          * the second number in each pair specifies the corresponding position
+          * in the source buffer. The pairs are sorted in ascending order.
+          *
+          * Since the mapping function is generally continuous, with successive
+          * positions in the string corresponding to successive positions in the
+          * source buffer, the table only needs to record discontinuities in
+          * the mapping. The values of intermediate positions can be inferred.
+          *
+          * Discontinuities may occur in a number of places: when a newline
+          * is followed by whitespace and asterisks (which are ignored),
+          * when a tab is expanded into spaces, and when unicode escapes
+          * are used in the source buffer.
+          *
+          * Thus, to find the source position of any position, p, in the comment
+          * string, find the index, i, of the pair whose string offset
+          * ({@code pbuf[i] }) is closest to but not greater than p. Then,
+          * {@code sourcePos(p) = pbuf[i+1] + (p - pbuf[i]) }.
+          */
+         int[] pbuf = new int[128];
+
+         /**
+          * The index of the next empty slot in the pbuf buffer.
+          */
+         int pp = 0;
+
+         DocReader(ScannerFactory fac, char[] input, int inputLength, int startPos) {
              super(fac, input, inputLength);
+             this.startPos = startPos;
          }
 
          @Override
@@ -147,19 +182,43 @@
                  break;
              }
          }
+
+         @Override
+         public void putChar(char ch, boolean scan) {
+             // At this point, bp is the position of the current character in buf,
+             // and sp is the position in sbuf where this character will be put.
+             // Record a new entry in pbuf if pbuf is empty or if sp and its
+             // corresponding source position are not equidistant from the
+             // corresponding values in the latest entry in the pbuf array.
+             // (i.e. there is a discontinuity in the map function.)
+             if ((pp == 0)
+                     || (sp - pbuf[pp - 2] != (startPos + bp) - pbuf[pp - 1])) {
+                 if (pp + 1 >= pbuf.length) {
+                     int[] new_pbuf = new int[pbuf.length * 2];
+                     System.arraycopy(pbuf, 0, new_pbuf, 0, pbuf.length);
+                     pbuf = new_pbuf;
+                 }
+                 pbuf[pp] = sp;
+                 pbuf[pp + 1] = startPos + bp;
+                 pp += 2;
+             }
+             super.putChar(ch, scan);
+         }
      }
 
-     protected class JavadocComment extends JavaTokenizer.BasicComment<ColReader> {
+     protected class JavadocComment extends JavaTokenizer.BasicComment<DocReader> {
 
         /**
         * Translated and stripped contents of doc comment
         */
         private String docComment = null;
+        private int[] docPosns = null;
 
-        JavadocComment(ColReader comment_reader, CommentStyle cs) {
-            super(comment_reader, cs);
+        JavadocComment(DocReader reader, CommentStyle cs) {
+            super(reader, cs);
         }
 
+        @Override
         public String getText() {
             if (!scanned && cs == CommentStyle.JAVADOC) {
                 scanDocComment();
@@ -168,6 +227,33 @@
         }
 
         @Override
+        public int getSourcePos(int pos) {
+            // Binary search to find the entry for which the string index is
+            // less than pos. Since docPosns is a list of pairs of integers
+            // we must make sure the index is always even.
+            // If we find an exact match for pos, the other item in the pair
+            // gives the source pos; otherwise, compute the source position
+            // relative to the best match found in the array.
+            if (pos < 0 || pos >= docComment.length())
+                throw new StringIndexOutOfBoundsException();
+            if (docPosns == null)
+                return -1;
+            int start = 0;
+            int end = docPosns.length;
+            while (start < end - 2) {
+                // find an even index midway between start and end
+                int index = ((start  + end) / 4) * 2;
+                if (docPosns[index] < pos)
+                    start = index;
+                else if (docPosns[index] == pos)
+                    return docPosns[index + 1];
+                else
+                    end = index;
+            }
+            return docPosns[start + 1] + (pos - docPosns[start]);
+        }
+
+        @Override
         @SuppressWarnings("fallthrough")
         protected void scanDocComment() {
              try {
@@ -209,7 +295,8 @@
                  // whitespace, then it consumes any stars, then it
                  // puts the rest of the line into our buffer.
                  while (comment_reader.bp < comment_reader.buflen) {
-
+                     int begin_bp = comment_reader.bp;
+                     char begin_ch = comment_reader.ch;
                      // The wsLoop consumes whitespace from the beginning
                      // of each line.
                  wsLoop:
@@ -263,10 +350,10 @@
                              break outerLoop;
                          }
                      } else if (! firstLine) {
-                         //The current line does not begin with a '*' so we will indent it.
-                         for (int i = 1; i < comment_reader.col; i++) {
-                             comment_reader.putChar(' ', false);
-                         }
+                         // The current line does not begin with a '*' so we will
+                         // treat it as comment
+                         comment_reader.bp = begin_bp;
+                         comment_reader.ch = begin_ch;
                      }
                      // The textLoop processes the rest of the characters
                      // on the line, adding them to our buffer.
@@ -334,11 +421,14 @@
 
                      // Store the text of the doc comment
                     docComment = comment_reader.chars();
+                    docPosns = new int[comment_reader.pp];
+                    System.arraycopy(comment_reader.pbuf, 0, docPosns, 0, docPosns.length);
                 } else {
                     docComment = "";
                 }
             } finally {
                 scanned = true;
+                comment_reader = null;
                 if (docComment != null &&
                         docComment.matches("(?sm).*^\\s*@deprecated( |$).*")) {
                     deprecatedFlag = true;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/parser/SimpleDocCommentTable.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.parser;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.DocCommentTable;
+import com.sun.tools.javac.tree.JCTree;
+
+
+/**
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own risk.
+ *  This code and its internal interfaces are subject to change or
+ *  deletion without notice.</b>
+ */
+public class SimpleDocCommentTable implements DocCommentTable {
+    Map<JCTree, Comment> table;
+
+    SimpleDocCommentTable() {
+        table = new HashMap<JCTree, Comment>();
+    }
+
+    public boolean hasComment(JCTree tree) {
+        return table.containsKey(tree);
+    }
+
+    public Comment getComment(JCTree tree) {
+        return table.get(tree);
+    }
+
+    public String getCommentText(JCTree tree) {
+        Comment c = getComment(tree);
+        return (c == null) ? null : c.getText();
+    }
+
+    public void putComment(JCTree tree, Comment c) {
+        table.put(tree, c);
+    }
+
+}
--- a/src/share/classes/com/sun/tools/javac/parser/Tokens.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/parser/Tokens.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -294,6 +294,7 @@
         }
 
         String getText();
+        int getSourcePos(int index);
         CommentStyle getStyle();
         boolean isDeprecated();
     }
@@ -371,11 +372,11 @@
          * Preserve classic semantics - if multiple javadocs are found on the token
          * the last one is returned
          */
-        public String comment(Comment.CommentStyle style) {
-            List<Comment> readers = getReaders(Comment.CommentStyle.JAVADOC);
-            return readers.isEmpty() ?
+        public Comment comment(Comment.CommentStyle style) {
+            List<Comment> comments = getComments(Comment.CommentStyle.JAVADOC);
+            return comments.isEmpty() ?
                     null :
-                    readers.head.getText();
+                    comments.head;
         }
 
         /**
@@ -383,22 +384,22 @@
          * javadoc comment attached to this token contains the '@deprecated' string
          */
         public boolean deprecatedFlag() {
-            for (Comment r : getReaders(Comment.CommentStyle.JAVADOC)) {
-                if (r.isDeprecated()) {
+            for (Comment c : getComments(Comment.CommentStyle.JAVADOC)) {
+                if (c.isDeprecated()) {
                     return true;
                 }
             }
             return false;
         }
 
-        private List<Comment> getReaders(Comment.CommentStyle style) {
+        private List<Comment> getComments(Comment.CommentStyle style) {
             if (comments == null) {
                 return List.nil();
             } else {
                 ListBuffer<Comment> buf = ListBuffer.lb();
-                for (Comment r : comments) {
-                    if (r.getStyle() == style) {
-                        buf.add(r);
+                for (Comment c : comments) {
+                    if (c.getStyle() == style) {
+                        buf.add(c);
                     }
                 }
                 return buf.toList();
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Aug 02 17:00:14 2012 +0100
@@ -419,9 +419,6 @@
 compiler.err.int.number.too.large=\
     integer number too large: {0}
 
-compiler.err.internal.error.cant.instantiate=\
-    internal error; cannot instantiate {0} at {1} to ({2})
-
 compiler.err.intf.annotation.members.cant.have.params=\
     @interface members may not have parameters
 
@@ -783,11 +780,6 @@
 compiler.err.undef.label=\
     undefined label: {0}
 
-# 0: list of type, 1: message segment
-compiler.misc.invalid.inferred.types=\
-    invalid inferred types for {0}\n\
-    reason: {1}
-
 # 0: message segment, 1: unused
 compiler.err.cant.apply.diamond=\
     cannot infer type arguments for {0}
@@ -1582,11 +1574,6 @@
 ## The following are all possible strings for the last argument of all those
 ## diagnostics whose key ends in ".1"
 
-# 0: type, 1: message segment
-compiler.misc.undetermined.type=\
-    cannot infer type arguments for {0}\n\
-    reason: {1}
-
 # 0: type, 1: list of type
 compiler.misc.no.unique.maximal.instance.exists=\
     no unique maximal instance exists for type variable {0} with upper bounds {1}
@@ -1983,10 +1970,6 @@
     ({2})
 
 # 0: type
-compiler.misc.full.inst.sig=\
-    fully instantiated to: {0}
-
-# 0: type
 compiler.misc.partial.inst.sig=\
     partially instantiated to: {0}
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/tree/DocCommentTable.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.sun.tools.javac.tree;
+
+import com.sun.tools.javac.parser.Tokens.Comment;
+
+/**
+ * A table giving the doc comment, if any, for any tree node.
+ *
+ *  <p><b>This is NOT part of any supported API.
+ *  If you write code that depends on this, you do so at your own
+ *  risk.  This code and its internal interfaces are subject to change
+ *  or deletion without notice.</b>
+ */
+public interface DocCommentTable {
+    /**
+     * Check if a tree node has a corresponding doc comment.
+     */
+    public boolean hasComment(JCTree tree);
+
+    /**
+     * Get the Comment token containing the doc comment, if any, for a tree node.
+     */
+    public Comment getComment(JCTree tree);
+
+    /**
+     * Get the plain text of the doc comment, if any, for a tree node.
+     */
+    public String getCommentText(JCTree tree);
+
+    /**
+     * Set the Comment to be associated with a tree node.
+     */
+    public void putComment(JCTree tree, Comment c);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/classes/com/sun/tools/javac/tree/EndPosTable.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.javac.tree;
+
+/**
+ * Specifies the methods to access a mappings of syntax trees to end positions.
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own
+ * risk.  This code and its internal interfaces are subject to change
+ * or deletion without notice.</b></p>
+ */
+public interface EndPosTable {
+
+    /**
+     * This method will return the end position of a given tree, otherwise a
+     * Positions.NOPOS will be returned.
+     * @param tree JCTree
+     * @return position of the source tree or Positions.NOPOS for non-existent mapping
+     */
+    public int getEndPos(JCTree tree);
+
+    /**
+     * Give an old tree and a new tree, the old tree will be replaced with
+     * the new tree, the position of the new tree will be that of the old
+     * tree.
+     * not exist.
+     * @param oldtree a JCTree to be replaced
+     * @param newtree a JCTree to be replaced with
+     * @return position of the old tree or Positions.NOPOS for non-existent mapping
+     */
+    public int replaceTree(JCTree oldtree, JCTree newtree);
+}
--- a/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/JCTree.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * 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,25 +25,23 @@
 
 package com.sun.tools.javac.tree;
 
+import java.io.IOException;
+import java.io.StringWriter;
 import java.util.*;
 
-import java.io.IOException;
-import java.io.StringWriter;
 import javax.lang.model.element.Modifier;
 import javax.lang.model.type.TypeKind;
 import javax.tools.JavaFileObject;
 
-import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.util.List;
+import com.sun.source.tree.*;
+import com.sun.source.tree.LambdaExpressionTree.BodyKind;
+import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
 import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.code.Scope.*;
 import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.parser.EndPosTable;
-import com.sun.source.tree.*;
-import com.sun.source.tree.LambdaExpressionTree.BodyKind;
-import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
-
+import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.List;
 import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 
@@ -491,7 +489,7 @@
         public ImportScope namedImportScope;
         public StarImportScope starImportScope;
         public Position.LineMap lineMap = null;
-        public Map<JCTree, String> docComments = null;
+        public DocCommentTable docComments = null;
         public EndPosTable endPositions = null;
         protected JCCompilationUnit(List<JCAnnotation> packageAnnotations,
                         JCExpression pid,
--- a/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/Pretty.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,14 +29,12 @@
 import java.util.*;
 
 import com.sun.source.tree.MemberReferenceTree.ReferenceMode;
-
+import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Symbol.*;
+import com.sun.tools.javac.parser.Tokens.Comment;
+import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.List;
-import com.sun.tools.javac.code.*;
-
-import com.sun.tools.javac.code.Symbol.*;
-import com.sun.tools.javac.tree.JCTree.*;
-
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Flags.ANNOTATION;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
@@ -78,10 +76,10 @@
      */
     Name enclClassName;
 
-    /** A hashtable mapping trees to their documentation comments
+    /** A table mapping trees to their documentation comments
      *  (can be null)
      */
-    Map<JCTree, String> docComments = null;
+    DocCommentTable docComments = null;
 
     /** Align code to be indented to left margin.
      */
@@ -233,7 +231,7 @@
      */
     public void printDocComment(JCTree tree) throws IOException {
         if (docComments != null) {
-            String dc = docComments.get(tree);
+            String dc = docComments.getCommentText(tree);
             if (dc != null) {
                 print("/**"); println();
                 int pos = 0;
@@ -480,7 +478,7 @@
 
     public void visitVarDef(JCVariableDecl tree) {
         try {
-            if (docComments != null && docComments.get(tree) != null) {
+            if (docComments != null && docComments.hasComment(tree)) {
                 println(); align();
             }
             printDocComment(tree);
--- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Thu Aug 02 17:00:14 2012 +0100
@@ -25,15 +25,14 @@
 
 package com.sun.tools.javac.tree;
 
+
 import com.sun.source.tree.Tree;
+import com.sun.tools.javac.code.*;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.tree.JCTree.*;
 import com.sun.tools.javac.util.*;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.code.*;
-import com.sun.tools.javac.parser.EndPosTable;
-import com.sun.tools.javac.tree.JCTree.*;
-
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK;
@@ -237,6 +236,15 @@
         }
     }
 
+    public static boolean isEnumInit(JCTree tree) {
+        switch (tree.getTag()) {
+            case VARDEF:
+                return (((JCVariableDecl)tree).mods.flags & ENUM) != 0;
+            default:
+                return false;
+        }
+    }
+
     /**
      * Return true if the AST corresponds to a static select of the kind A.B
      */
@@ -273,6 +281,13 @@
         return (lit.typetag == TypeTags.BOT);
     }
 
+    public static String getCommentText(Env<?> env, JCTree tree) {
+        DocCommentTable docComments = (tree.hasTag(JCTree.Tag.TOPLEVEL))
+                ? ((JCCompilationUnit) tree).docComments
+                : env.toplevel.docComments;
+        return (docComments == null) ? null : docComments.getCommentText(tree);
+    }
+
     /** The position of the first statement in a block, or the position of
      *  the block itself if it is empty.
      */
--- a/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/DiagnosticSource.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,7 @@
 import javax.tools.JavaFileObject;
 
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 
 import static com.sun.tools.javac.util.LayoutCharacters.*;
--- a/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/JCDiagnostic.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,7 @@
 
 import com.sun.tools.javac.api.DiagnosticFormatter;
 import com.sun.tools.javac.code.Lint.LintCategory;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 
 import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticType.*;
--- a/src/share/classes/com/sun/tools/javac/util/Log.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javac/util/Log.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -37,7 +37,7 @@
 import com.sun.tools.javac.api.DiagnosticFormatter;
 import com.sun.tools.javac.main.Main;
 import com.sun.tools.javac.main.Option;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
 
--- a/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocEnter.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
  * 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,14 +25,17 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
-import com.sun.tools.javac.util.List;
+
+import javax.tools.JavaFileObject;
+
 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 javax.tools.JavaFileObject;
+import com.sun.tools.javac.tree.TreeInfo;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
+import com.sun.tools.javac.util.List;
 
 /**
  *  Javadoc's own enter phase does a few things above and beyond that
@@ -77,7 +80,7 @@
     public void visitTopLevel(JCCompilationUnit tree) {
         super.visitTopLevel(tree);
         if (tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
-            String comment = tree.docComments.get(tree);
+            String comment = TreeInfo.getCommentText(env, tree);
             docenv.makePackageDoc(tree.packge, comment, tree);
         }
     }
@@ -87,7 +90,7 @@
         super.visitClassDef(tree);
         if (tree.sym == null) return;
         if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) {
-            String comment = env.toplevel.docComments.get(tree);
+            String comment = TreeInfo.getCommentText(env, tree);
             ClassSymbol c = tree.sym;
             docenv.makeClassDoc(c, comment, tree, env.toplevel.lineMap);
         }
--- a/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Tue May 29 00:27:58 2012 +0100
+++ b/src/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * 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,13 +25,14 @@
 
 package com.sun.tools.javadoc;
 
-import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.Position;
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.MemberEnter;
 import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.TreeInfo;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Position;
 
 /**
  *  Javadoc's own memberEnter phase does a few things above and beyond that
@@ -61,11 +62,12 @@
         docenv = DocEnv.instance(context);
     }
 
+    @Override
     public void visitMethodDef(JCMethodDecl tree) {
         super.visitMethodDef(tree);
         MethodSymbol meth = tree.sym;
         if (meth == null || meth.kind != Kinds.MTH) return;
-        String docComment = env.toplevel.docComments.get(tree);
+        String docComment = TreeInfo.getCommentText(env, tree);
         Position.LineMap lineMap = env.toplevel.lineMap;
         if (meth.isConstructor())
             docenv.makeConstructorDoc(meth, docComment, tree, lineMap);
@@ -75,12 +77,13 @@
             docenv.makeMethodDoc(meth, docComment, tree, lineMap);
     }
 
+    @Override
     public void visitVarDef(JCVariableDecl tree) {
         super.visitVarDef(tree);
         if (tree.sym != null &&
                 tree.sym.kind == Kinds.VAR &&
                 !isParameter(tree.sym)) {
-            String docComment = env.toplevel.docComments.get(tree);
+            String docComment = TreeInfo.getCommentText(env, tree);
             Position.LineMap lineMap = env.toplevel.lineMap;
             docenv.makeFieldDoc(tree.sym, docComment, tree, lineMap);
         }
--- a/test/tools/javac/6304921/TestLog.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/6304921/TestLog.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,9 +33,9 @@
 import javax.tools.JavaFileObject;
 import javax.tools.SimpleJavaFileObject;
 import com.sun.tools.javac.file.JavacFileManager;
-import com.sun.tools.javac.parser.EndPosTable;
 import com.sun.tools.javac.parser.Parser;
 import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.Context;
--- a/test/tools/javac/6758789/T6758789b.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/6758789/T6758789b.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,4 +1,4 @@
-T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X>
+T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<java.lang.Object>
 T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a
 - compiler.err.warnings.and.werror
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/T7159016.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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 7159016
+ * @summary Static import of member in processor-generated class fails in JDK 7
+ * @library lib
+ * @build JavacTestingAbstractProcessor
+ * @run main T7159016
+ * @author Jessie Glick
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Collections;
+import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.JavaCompiler;
+import javax.tools.ToolProvider;
+
+public class T7159016 {
+    public static void main(String[] args) throws Exception {
+        File src = new File("C.java");
+        Writer w = new FileWriter(src);
+        try {
+            w.write("import static p.Generated.m;\nclass C { {m(); } }\n");
+            w.flush();
+        } finally {
+            w.close();
+        }
+        JavaCompiler jc = ToolProvider.getSystemJavaCompiler();
+        JavaCompiler.CompilationTask task = jc.getTask(null, null, null, null, null,
+                                                       jc.getStandardFileManager(null, null, null).getJavaFileObjects(src));
+        task.setProcessors(Collections.singleton(new Proc()));
+        if (!task.call()) {
+            throw new Error("Test failed");
+        }
+    }
+
+    private static class Proc extends JavacTestingAbstractProcessor {
+        int written;
+        @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+            if (roundEnv.processingOver() || written++ > 0) {
+                return false;
+            }
+            messager.printMessage(Diagnostic.Kind.NOTE, "writing Generated.java");
+            try {
+                Writer w = processingEnv.getFiler().createSourceFile("p.Generated").openWriter();
+                try {
+                    w.write("package p; public class Generated { public static void m() { } }");
+                } finally {
+                    w.close();
+                }
+            } catch (IOException x) {
+                messager.printMessage(Diagnostic.Kind.ERROR, x.toString());
+            }
+            return true;
+        }
+    }
+}
--- a/test/tools/javac/diags/examples.not-yet.txt	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/diags/examples.not-yet.txt	Thu Aug 02 17:00:14 2012 +0100
@@ -5,7 +5,6 @@
 compiler.err.cant.read.file                             # (apt.JavaCompiler?)
 compiler.err.cant.select.static.class.from.param.type
 compiler.err.illegal.char.for.encoding
-compiler.err.internal.error.cant.instantiate            # Attr: should not happen
 compiler.err.io.exception                               # (javah.JavahTask?)
 compiler.err.limit.code                                 # Code
 compiler.err.limit.code.too.large.for.try.stmt          # Gen
--- a/test/tools/javac/diags/examples/ApplicableMethodFound1.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/diags/examples/ApplicableMethodFound1.java	Thu Aug 02 17:00:14 2012 +0100
@@ -23,7 +23,7 @@
 
 // key: compiler.misc.applicable.method.found.1
 // key: compiler.note.verbose.resolve.multi
-// key: compiler.misc.full.inst.sig
+// key: compiler.misc.partial.inst.sig
 // options: -XDverboseResolution=applicable,success
 
 class ApplicableMethodFound1 {
--- a/test/tools/javac/diags/examples/CantApplyDiamond1.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/diags/examples/CantApplyDiamond1.java	Thu Aug 02 17:00:14 2012 +0100
@@ -23,7 +23,7 @@
 
 // key: compiler.err.prob.found.req.1
 // key: compiler.misc.cant.apply.diamond.1
-// key: compiler.misc.no.conforming.assignment.exists
+// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
 // key: compiler.misc.diamond
 
 class CantApplyDiamond1<X> {
--- a/test/tools/javac/diags/examples/FullInstSig.java	Tue May 29 00:27:58 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.misc.applicable.method.found.1
-// key: compiler.note.verbose.resolve.multi
-// key: compiler.misc.full.inst.sig
-// options: -XDverboseResolution=applicable,success
-
-class FullInstSig {
-
-    <X> void m(X x) {}
-
-    { m(1); }
-}
--- a/test/tools/javac/diags/examples/IncompatibleTypes1.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java	Thu Aug 02 17:00:14 2012 +0100
@@ -22,7 +22,7 @@
  */
 
 // key: compiler.misc.infer.no.conforming.instance.exists
-// key: compiler.err.prob.found.req.1
+// key: compiler.err.cant.apply.symbol.1
 
 class IncompatibleTypes1<V> {
     <T> IncompatibleTypes1<Integer> m() {
--- a/test/tools/javac/diags/examples/InferredDoNotConformToLower.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/diags/examples/InferredDoNotConformToLower.java	Thu Aug 02 17:00:14 2012 +0100
@@ -21,8 +21,7 @@
  * questions.
  */
 
-// key: compiler.misc.invalid.inferred.types
-// key: compiler.err.prob.found.req.1
+// key: compiler.err.cant.apply.symbol.1
 // key: compiler.misc.inferred.do.not.conform.to.lower.bounds
 
 import java.util.*;
--- a/test/tools/javac/diags/examples/InvalidInferredTypes.java	Tue May 29 00:27:58 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
- * 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.prob.found.req.1
-// key: compiler.misc.invalid.inferred.types
-// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
-
-import java.util.*;
-
-class InvalidInferredTypes {
-
-    <S extends String> List<S> m() { return null; }
-
-    void test() {
-        List<Integer> li = m();
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/diags/examples/NoUniqueMaximalInstance.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.no.unique.maximal.instance.exists
+
+class NoUniqueMaximalInstance {
+    <Z extends Integer> Z m() { return null; }
+
+    { String s = m(); }
+}
--- a/test/tools/javac/diags/examples/UndeterminedType1.java	Tue May 29 00:27:58 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-// key: compiler.err.prob.found.req.1
-// key: compiler.misc.undetermined.type
-// key: compiler.misc.no.unique.maximal.instance.exists
-
-class UndeterminedType1<V> {
-    <T extends Integer & Runnable> UndeterminedType1<T> m() {
-        return null;
-    }
-
-
-    UndeterminedType1<? extends String> c2 = m();
-}
--- a/test/tools/javac/diags/examples/WhereFreshTvar.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/diags/examples/WhereFreshTvar.java	Thu Aug 02 17:00:14 2012 +0100
@@ -22,10 +22,9 @@
  */
 
 // key: compiler.misc.where.fresh.typevar
-// key: compiler.misc.where.description.typevar.1
-// key: compiler.misc.where.typevar
-// key: compiler.misc.invalid.inferred.types
-// key: compiler.err.prob.found.req.1
+// key: compiler.misc.where.description.typevar
+// key: compiler.err.cant.apply.symbol.1
+// key: compiler.misc.no.args
 // key: compiler.misc.inferred.do.not.conform.to.upper.bounds
 // options: -XDdiags=where,simpleNames
 // run: simple
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/enum/7160084/T7160084a.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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     7160084
+ * @summary javac fails to compile an apparently valid class/interface combination
+ */
+public class T7160084a {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond) {
+            throw new AssertionError();
+        }
+    }
+
+    interface Intf {
+       enum MyEnumA {
+          AA(""),
+          UNUSED("");
+
+          private MyEnumA(String s) { }
+       }
+    }
+
+    enum MyEnumA implements Intf {
+        AA("");
+
+        private MyEnumA(String s) { }
+    }
+
+    public static void main(String... args) {
+        assertTrue(MyEnumA.values().length == 1);
+        assertTrue(Intf.MyEnumA.values().length == 2);
+        assertTrue(assertionCount == 2);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/enum/7160084/T7160084b.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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     7160084
+ * @summary javac fails to compile an apparently valid class/interface combination
+ */
+public class T7160084b {
+
+    static int assertionCount = 0;
+
+    static void assertTrue(boolean cond) {
+        assertionCount++;
+        if (!cond) {
+            throw new AssertionError();
+        }
+    }
+
+    interface Extras {
+        static class Enums {
+            static class Component {
+                Component() { throw new RuntimeException("oops!"); }
+            }
+        }
+    }
+
+    interface Test {
+        public class Enums {
+            interface Widget {
+                enum Component { X, Y };
+            }
+
+            enum Component implements Widget, Extras {
+                Z;
+            };
+
+            public static void test() {
+               assertTrue(Component.values().length == 1);
+            }
+        }
+    }
+
+    public static void main(String[] args) {
+        Test.Enums.test();
+        assertTrue(assertionCount == 1);
+    }
+}
--- a/test/tools/javac/failover/CheckAttributedTree.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/failover/CheckAttributedTree.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -68,7 +68,7 @@
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.tree.JCTree.JCImport;
--- a/test/tools/javac/generics/7015430/T7015430.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/generics/7015430/T7015430.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,14 +1,14 @@
-T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
 T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
 T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
 T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
 T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException>
 T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
-T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E>
+T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception>
 T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430
 T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
 T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
--- a/test/tools/javac/generics/7151802/T7151802.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/generics/7151802/T7151802.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802
-T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<Z>
+T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.Object>
 T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo<Z>, T7151802.Foo, kindname.class, T7151802
 T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802
 T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.String>
--- a/test/tools/javac/generics/inference/6315770/T6315770.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/generics/inference/6315770/T6315770.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,3 +1,3 @@
-T6315770.java:16:42: compiler.err.prob.found.req.1: (compiler.misc.undetermined.type: <T>T6315770<T>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable))
-T6315770.java:17:40: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer&java.lang.Runnable, java.lang.String))
+T6315770.java:16:42: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T6315770<V>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)
+T6315770.java:17:40: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T6315770<V>, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer&java.lang.Runnable, java.lang.String)
 2 errors
--- a/test/tools/javac/generics/inference/6638712/T6638712b.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712b.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,2 +1,2 @@
-T6638712b.java:14:21: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String,java.lang.Object))
+T6638712b.java:14:21: compiler.err.cant.apply.symbol.1: kindname.method, m, I, T6638712b<java.lang.Integer>, kindname.class, T6638712b<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String,java.lang.Object)
 1 error
--- a/test/tools/javac/generics/inference/6638712/T6638712e.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/generics/inference/6638712/T6638712e.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,2 +1,2 @@
-T6638712e.java:17:27: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.no.conforming.assignment.exists: T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>, T6638712e.Foo<? super java.lang.Object,? extends java.lang.Boolean>))
+T6638712e.java:17:27: compiler.err.cant.apply.symbol.1: kindname.method, m, T6638712e.Foo<? super X,? extends A>, T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>, kindname.class, T6638712e.Foo<A,B>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object, java.lang.Boolean,java.lang.Object)
 1 error
--- a/test/tools/javac/generics/inference/6650759/T6650759m.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/generics/inference/6650759/T6650759m.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,2 +1,2 @@
-T6650759m.java:43:36: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: Z, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer, java.lang.String))
+T6650759m.java:43:36: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? extends java.util.List<? super Z>>, java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>, kindname.class, T6650759m, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer, java.lang.String)
 1 error
--- a/test/tools/javac/generics/inference/7154127/T7154127.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/generics/inference/7154127/T7154127.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,2 +1,2 @@
-T7154127.java:19:49: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T,Y,U, (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B<U>))
+T7154127.java:19:49: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7154127, (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B<U>)
 1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test1.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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 7157798
+ * @summary  Test inheritance of same-name methods from mulitple interfaces
+             when the methods have compatible return types
+ * @compile  Test1.java
+ */
+
+import java.util.*;
+
+interface A { List<Number> getList(); }
+interface B { List getList(); }
+
+interface AB extends A, B {} //return type: List<Number>
+
+interface C<T> { List<T> getList(); }
+
+interface BC<T> extends B, C<T> {} //return type: List<T>
+
+interface D { Number m(); }
+interface E { Double m(); }
+
+interface DE extends D, E {} //return type: Double
+
+interface F { ArrayList getList(); }
+interface G { Collection getList(); }
+
+interface AG extends A, G{}; //return type: List<Number>
+
+interface CF<T> extends C<T>, F {} //return type: ArrayList
+
+interface CG<T> extends C<T>, G {} //return type: List<T>
+
+interface H<T> { Iterable<T> getList(); }
+
+interface CH<T> extends C<T>, H<T> {} //return type: List<T>
+
+interface CFGH<T> extends C<T>, F, G, H<T> {} //return type: ArrayList
+
+
+class Test1 {
+
+    //raw and typed return types:
+    void test(AB ab) {
+        Number n = ab.getList().get(1);
+    }
+
+    void test(BC<String> bc) {
+        String s = bc.getList().get(1);
+    }
+
+    void testRaw(BC bc) {
+        List list = bc.getList();
+    }
+
+    void testWildCard(BC<?> bc) {
+        List<?> list = bc.getList();
+    }
+
+    <T> void testGeneric(BC<T> bc) {
+        T t = bc.getList().get(1);
+    }
+
+    //covariant return:
+    void test(DE de) {
+        Double d = de.m();
+    }
+
+    //mixed:
+    void test(AG ag) {
+        Number n = ag.getList().get(0);
+    }
+
+    void test(CF<Integer> cf) {
+        ArrayList list = cf.getList();
+    }
+
+    void test(CG<String> cg) {
+        String s = cg.getList().get(0);
+    }
+
+    void test(CH<String> ch) {
+        String s = ch.getList().get(0);
+    }
+
+    void test(CFGH<Double> cfgh) {
+        ArrayList list = cfgh.getList();
+    }
+
+    void testWildCard(CFGH<?> cfgh) {
+        ArrayList list = cfgh.getList();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test2.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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 7157798
+ * @summary  Test inheritance of same-name methods from multiple interfaces
+             when the methods have compatible parameter types and return types
+ * @compile  Test2.java
+ */
+
+import java.util.*;
+
+interface A { void m(Map map); }
+interface B { void m(Map<Number, String> map); }
+
+interface AB extends A, B {} //paramter type: Map<Number, String>
+
+interface C<K, V> { List<V> getList(Map<K, V> map); }
+interface D { ArrayList getList(Map map); }
+
+interface CD<K, V> extends C<K, V>, D {} //paramter type: Map<K, V>
+
+interface E<T> { T get(List<?> list); }
+interface F<T> { T get(List list); }
+
+interface EF<T1, T2 extends T1> extends E<T1>, F<T2> {} //parameter type: List<?>
+
+class Test2 {
+
+    //compatible parameter types:
+    void test(AB ab) {
+        ab.m(new HashMap<Number, String>());
+    }
+
+    //compatible parameter types and return types:
+    void testRaw(CD cd) { //return type: ArrayList
+        ArrayList al = cd.getList(new HashMap());
+    }
+
+    <K, V> void testGeneric(CD<K, V> cd) { //return type: List<V>
+        V v = cd.getList(new HashMap<K, V>()).get(0);
+    }
+
+    void test(CD<Number, String> cd) { //return type: List<String>
+        String s = cd.getList(new HashMap<Number, String>()).get(0);
+    }
+
+    void test(EF<Number, Integer> ef) { //return type: Number
+        Number n = ef.get(new ArrayList<Integer>());
+    }
+
+    <T, U extends T> void testGeneric(EF<T, U> ef) { //return type: T
+        T t = ef.get(new ArrayList<U>());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test3.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,37 @@
+/**
+ * @test     /nodynamiccopyright/
+ * @bug      7062745 7157798
+ * @summary  Negative test of conflicting same-name methods inherited from multiple interfaces when return type not compatible
+ * @compile/fail/ref=Test3.out -Werror -Xlint:unchecked -XDrawDiagnostics Test3.java
+ */
+
+import java.util.List;
+import java.io.Serializable;
+
+interface A { int m(); }
+interface B { Integer m(); }
+
+interface AB extends A, B {} //error
+
+interface C { List<Integer> m(); }
+interface D { List<Number> m(); }
+
+interface CD extends C, D {} //error
+
+interface E<T> { T m(); }
+interface F<T> { T m(); }
+interface G { Serializable m(); }
+
+interface BE extends B, E<Number> {} //ok, covariant return
+
+interface BE2<T> extends B, E<T> {} //error
+
+interface EF<T> extends E<T>, F<T> {} //ok
+
+interface EF2<U, V extends U> extends E<U>, F<V> {} //ok, covariant return
+
+interface EF3<U, V> extends E<U>, F<V> {} //error
+
+interface EG<T extends Number> extends E<T>, G {} //ok
+
+interface EFG<U extends Serializable, V extends Serializable> extends E<U>, F<V>, G {} //error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test3.out	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,6 @@
+Test3.java:14:1: compiler.err.types.incompatible.diff.ret: B, A, m()
+Test3.java:19:1: compiler.err.types.incompatible.diff.ret: D, C, m()
+Test3.java:27:1: compiler.err.types.incompatible.diff.ret: E<T>, B, m()
+Test3.java:33:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m()
+Test3.java:37:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m()
+5 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test4.java	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,29 @@
+/**
+ * @test     /nodynamiccopyright/
+ * @bug      7062745 7157798
+ * @summary  Negative test of conflicting same-name methods inherited from multiple interfaces when parameter types not compatible
+ * @compile/fail/ref=Test4.out -Werror -Xlint:unchecked -XDrawDiagnostics Test4.java
+ */
+
+import java.util.Set;
+import java.util.HashSet;
+
+interface A { void m(Set<Integer> s); }
+interface B { void m(Set<String> s); }
+interface C { void m(Set<?> s); }
+
+interface AB extends A, B {} //error
+
+interface AC extends A, C {} //error
+
+interface D<T> { void m(Set<T> s); }
+
+interface AD extends A, D<Integer> {} //OK
+
+interface AD2 extends A, D<Number> {} //error
+
+interface CD<T> extends C, D<T> {} //error
+
+interface E { <T> void m(Set<T> s); }
+
+interface DE<T> extends D<T>, E {} //error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/rawOverride/7157798/Test4.out	Thu Aug 02 17:00:14 2012 +0100
@@ -0,0 +1,6 @@
+Test4.java:15:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<java.lang.String>), B, m(java.util.Set<java.lang.Integer>), A
+Test4.java:17:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<?>), C, m(java.util.Set<java.lang.Integer>), A
+Test4.java:23:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<java.lang.Integer>), A
+Test4.java:25:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<?>), C
+Test4.java:29:1: compiler.err.name.clash.same.erasure.no.override: <T>m(java.util.Set<T>), E, m(java.util.Set<T>), D
+5 errors
--- a/test/tools/javac/parser/JavacParserTest.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/parser/JavacParserTest.java	Thu Aug 02 17:00:14 2012 +0100
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 7073631 7159445
+ * @bug 7073631 7159445 7156633
  * @summary tests error and diagnostics positions
  * @author  Jan Lahoda
  */
@@ -49,11 +49,17 @@
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.tree.JCTree;
 import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Method;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.regex.Pattern;
 import javax.tools.Diagnostic;
 import javax.tools.DiagnosticCollector;
 import javax.tools.DiagnosticListener;
@@ -63,13 +69,15 @@
 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 final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+
+    private JavacParserTest(){}
+
+    public static void main(String... args) throws Exception {
+        new JavacParserTest().run(args);
     }
 
-    static class MyFileObject extends SimpleJavaFileObject {
+    class MyFileObject extends SimpleJavaFileObject {
 
         private String text;
 
@@ -86,11 +94,11 @@
     /*
      * converts Windows to Unix style LFs for comparing strings
      */
-    private String normalize(String in) {
+    String normalize(String in) {
         return in.replace(System.getProperty("line.separator"), "\n");
     }
 
-    public CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
+    CompilationUnitTree getCompilationUnitTree(String code) throws IOException {
 
         JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
                 null, Arrays.asList(new MyFileObject(code)));
@@ -98,7 +106,7 @@
         return cut;
     }
 
-    public List<String> getErroneousTreeValues(ErroneousTree node) {
+    List<String> getErroneousTreeValues(ErroneousTree node) {
 
         List<String> values = new ArrayList<>();
         if (node.getErrorTrees() != null) {
@@ -112,7 +120,8 @@
         return values;
     }
 
-    public void testPositionForSuperConstructorCalls() throws IOException {
+    @Test
+    void testPositionForSuperConstructorCalls() throws IOException {
         assert tool != null;
 
         String code = "package test; public class Test {public Test() {super();}}";
@@ -149,12 +158,12 @@
                 methodStartPos, pos.getStartPosition(cut, mit.getMethodSelect()));
         assertEquals("testPositionForSuperConstructorCalls",
                 methodEndPos, pos.getEndPosition(cut, mit.getMethodSelect()));
-
     }
 
-    public void testPositionForEnumModifiers() throws IOException {
-
-        String code = "package test; public enum Test {A;}";
+    @Test
+    void testPositionForEnumModifiers() throws IOException {
+        final String theString = "public";
+        String code = "package test; " + theString + " enum Test {A;}";
 
         JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
                 null, Arrays.asList(new MyFileObject(code)));
@@ -163,19 +172,21 @@
 
         ClassTree clazz = (ClassTree) cut.getTypeDecls().get(0);
         ModifiersTree mt = clazz.getModifiers();
-
+        int spos = code.indexOf(theString);
+        int epos = spos + theString.length();
         assertEquals("testPositionForEnumModifiers",
-                38 - 24, pos.getStartPosition(cut, mt));
+                spos, pos.getStartPosition(cut, mt));
         assertEquals("testPositionForEnumModifiers",
-                44 - 24, pos.getEndPosition(cut, mt));
+                epos, pos.getEndPosition(cut, mt));
     }
 
-    public void testNewClassWithEnclosing() throws IOException {
+    @Test
+    void testNewClassWithEnclosing() throws IOException {
 
-
+        final String theString = "Test.this.new d()";
         String code = "package test; class Test { " +
                 "class d {} private void method() { " +
-                "Object o = Test.this.new d(); } }";
+                "Object o = " + theString + "; } }";
 
         JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, null, null,
                 null, Arrays.asList(new MyFileObject(code)));
@@ -186,13 +197,16 @@
         ExpressionTree est =
                 ((VariableTree) ((MethodTree) clazz.getMembers().get(1)).getBody().getStatements().get(0)).getInitializer();
 
+        final int spos = code.indexOf(theString);
+        final int epos = spos + theString.length();
         assertEquals("testNewClassWithEnclosing",
-                97 - 24, pos.getStartPosition(cut, est));
+                spos, pos.getStartPosition(cut, est));
         assertEquals("testNewClassWithEnclosing",
-                114 - 24, pos.getEndPosition(cut, est));
+                epos, pos.getEndPosition(cut, est));
     }
 
-    public void testPreferredPositionForBinaryOp() throws IOException {
+    @Test
+    void testPreferredPositionForBinaryOp() throws IOException {
 
         String code = "package test; public class Test {"
                 + "private void test() {"
@@ -211,7 +225,581 @@
                 condStartPos, condJC.pos);
     }
 
-    public void testPositionBrokenSource126732a() throws IOException {
+    @Test
+    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());
+    }
+
+    @Test
+    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));
+    }
+
+    @Test
+    void testPositionsSane1() throws IOException {
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? extends java.util.List<? extends String>> l; " +
+                "} }");
+    }
+
+    @Test
+    void testPositionsSane2() throws IOException {
+        performPositionsSanityTest("package test; class Test { " +
+                "private void method() { " +
+                "java.util.List<? super java.util.List<? super String>> l; " +
+                "} }");
+    }
+
+    @Test
+    void testPositionsSane3() throws IOException {
+        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);
+    }
+
+    @Test
+    void testCorrectWilcardPositions1() 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"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions2() throws IOException {
+        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"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions3() throws IOException {
+        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",
+                "?"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions4() throws IOException {
+        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"));
+    }
+
+    @Test
+    void testCorrectWilcardPositions5() throws IOException {
+        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"));
+    }
+
+    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());
+    }
+
+    @Test
+    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));
+    }
+
+    @Test
+    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);
+    }
+
+    @Test
+   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);
+    }
+
+    @Test
+    void testVariableInIfThen3() throws IOException {
+
+        String code = "package t; class Test { "+
+                "private static void t() { " +
+                "if (true) abstract class F {} }}";
+        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.class.not.allowed"), codes);
+    }
+
+    @Test
+    void testVariableInIfThen4() throws IOException {
+
+        String code = "package t; class Test { "+
+                "private static void t(String name) { " +
+                "if (name != null) interface 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("testVariableInIfThen4",
+                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
+    }
+
+    @Test
+    void testVariableInIfThen5() throws IOException {
+
+        String code = "package t; class Test { "+
+                "private static void t() { " +
+                "if (true) } }";
+        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("testVariableInIfThen5",
+                Arrays.<String>asList("compiler.err.illegal.start.of.stmt"),
+                codes);
+    }
+
+    // see javac bug #6882235, NB bug #98234:
+    @Test
+    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());
+    }
+
+    @Test
+    void testTryResourcePos() throws IOException {
+
+        final String code = "package t; class Test { " +
+                "{ try (java.io.InputStream in = null) { } } }";
+
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitVariable(VariableTree node, Void p) {
+                if ("in".contentEquals(node.getName())) {
+                    JCTree.JCVariableDecl var = (JCTree.JCVariableDecl) node;
+                    assertEquals("testTryResourcePos", "in = null) { } } }",
+                            code.substring(var.pos));
+                }
+                return super.visitVariable(node, p);
+            }
+        }.scan(cut, null);
+    }
+
+    @Test
+    void testVarPos() throws IOException {
+
+        final String code = "package t; class Test { " +
+                "{ java.io.InputStream in = null; } }";
+
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+
+        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);
+    }
+
+    // expected erroneous tree: int x = y;(ERROR);
+    @Test
+    void testOperatorMissingError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "void method() { int x = y  z } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[z]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree:  String s = (ERROR);
+    @Test
+    void testMissingParenthesisError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "void f() {String s = new String; } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[new String()]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree: package test; (ERROR)(ERROR)
+    @Test
+    void testMissingClassError() throws IOException {
+
+        String code = "package Test; clas ErrorTest {  "
+                + "void f() {String s = new String(); } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[, clas]", "[]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree: void m1(int i) {(ERROR);{(ERROR);}
+    @Test
+    void testSwitchError() throws IOException {
+
+        String code = "package test; public class ErrorTest { "
+                + "int numDays; void m1(int i) { switchh {i} { case 1: "
+                + "numDays = 31; break; } } }";
+        CompilationUnitTree cut = getCompilationUnitTree(code);
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[switchh]", "[i]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(getErroneousTreeValues(node).toString());
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testSwitchError: The Erroneous tree "
+                + "error values: " + values
+                + " do not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    // expected erroneous tree: class ErrorTest {(ERROR)
+    @Test
+    void testMethodError() throws IOException {
+
+        String code = "package Test; class ErrorTest {  "
+                + "static final void f) {String s = new String(); } }";
+        CompilationUnitTree cut = cut = getCompilationUnitTree(code);
+
+        final List<String> values = new ArrayList<>();
+        final List<String> expectedValues =
+                new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));
+
+        new TreeScanner<Void, Void>() {
+            @Override
+            public Void visitErroneous(ErroneousTree node, Void p) {
+                values.add(normalize(getErroneousTreeValues(node).toString()));
+                return null;
+            }
+        }.scan(cut, null);
+
+        assertEquals("testMethodError: The Erroneous tree "
+                + "error value: " + values
+                + " does not match expected error values: "
+                + expectedValues, values, expectedValues);
+    }
+
+    /*
+     * The following tests do not work just yet with nb-javac nor javac,
+     * they need further investigation, see CR: 7167356
+     */
+
+    void testPositionBrokenSource126732a() throws IOException {
         String[] commands = new String[]{
             "return Runnable()",
             "do { } while (true)",
@@ -250,7 +838,7 @@
         }
     }
 
-    public void testPositionBrokenSource126732b() throws IOException {
+    void testPositionBrokenSource126732b() throws IOException {
         String[] commands = new String[]{
             "break",
             "break A",
@@ -291,246 +879,7 @@
         }
     }
 
-    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 {
+    void testStartPositionEnumConstantInit() throws IOException {
 
         String code = "package t; enum Test { AAA; }";
 
@@ -546,342 +895,34 @@
         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() { " +
-                "if (true) abstract class F {} }}";
-        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.class.not.allowed"), codes);
-    }
-
-    public void testVariableInIfThen4() throws IOException {
-
-        String code = "package t; class Test { "+
-                "private static void t(String name) { " +
-                "if (name != null) interface 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("testVariableInIfThen4",
-                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
-    }
-
-    public void testVariableInIfThen5() throws IOException {
-
-        String code = "package t; class Test { "+
-                "private static void t() { " +
-                "if (true) } }";
-        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("testVariableInIfThen5",
-                Arrays.<String>asList("compiler.err.illegal.start.of.stmt"),
-                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) { } } }";
-
-        CompilationUnitTree cut = getCompilationUnitTree(code);
-
-        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));
+    void run(String[] args) throws Exception {
+        int passed = 0, failed = 0;
+        final Pattern p = (args != null && args.length > 0)
+                ? Pattern.compile(args[0])
+                : null;
+        for (Method m : this.getClass().getDeclaredMethods()) {
+            boolean selected = (p == null)
+                    ? m.isAnnotationPresent(Test.class)
+                    : p.matcher(m.getName()).matches();
+            if (selected) {
+                try {
+                    m.invoke(this, (Object[]) null);
+                    System.out.println(m.getName() + ": OK");
+                    passed++;
+                } catch (Throwable ex) {
+                    System.out.printf("Test %s failed: %s %n", m, ex.getCause());
+                    failed++;
                 }
-                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; } }";
-
-        CompilationUnitTree cut = getCompilationUnitTree(code);
-
-        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);
-    }
-
-    // expected erroneous tree: int x = y;(ERROR);
-    public void testOperatorMissingError() throws IOException {
-
-        String code = "package test; public class ErrorTest { "
-                + "void method() { int x = y  z } }";
-        CompilationUnitTree cut = getCompilationUnitTree(code);
-        final List<String> values = new ArrayList<>();
-        final List<String> expectedValues =
-                new ArrayList<>(Arrays.asList("[z]"));
-
-        new TreeScanner<Void, Void>() {
-
-            @Override
-            public Void visitErroneous(ErroneousTree node, Void p) {
-
-                values.add(getErroneousTreeValues(node).toString());
-                return null;
-
-            }
-        }.scan(cut, null);
-
-        assertEquals("testSwitchError: The Erroneous tree "
-                + "error values: " + values
-                + " do not match expected error values: "
-                + expectedValues, values, expectedValues);
-    }
-
-    //expected erroneous tree:  String s = (ERROR);
-    public void testMissingParenthesisError() throws IOException {
-
-        String code = "package test; public class ErrorTest { "
-                + "void f() {String s = new String; } }";
-        CompilationUnitTree cut = getCompilationUnitTree(code);
-        final List<String> values = new ArrayList<>();
-        final List<String> expectedValues =
-                new ArrayList<>(Arrays.asList("[new String()]"));
-
-        new TreeScanner<Void, Void>() {
-
-            @Override
-            public Void visitErroneous(ErroneousTree node, Void p) {
-
-                values.add(getErroneousTreeValues(node).toString());
-                return null;
-            }
-        }.scan(cut, null);
-
-        assertEquals("testSwitchError: The Erroneous tree "
-                + "error values: " + values
-                + " do not match expected error values: "
-                + expectedValues, values, expectedValues);
-    }
-
-    //expected erroneous tree: package test; (ERROR)(ERROR)
-    public void testMissingClassError() throws IOException {
-
-        String code = "package Test; clas ErrorTest {  "
-                + "void f() {String s = new String(); } }";
-        CompilationUnitTree cut = getCompilationUnitTree(code);
-        final List<String> values = new ArrayList<>();
-        final List<String> expectedValues =
-                new ArrayList<>(Arrays.asList("[, clas]", "[]"));
-
-        new TreeScanner<Void, Void>() {
-
-            @Override
-            public Void visitErroneous(ErroneousTree node, Void p) {
-
-                values.add(getErroneousTreeValues(node).toString());
-                return null;
-            }
-        }.scan(cut, null);
-
-        assertEquals("testSwitchError: The Erroneous tree "
-                + "error values: " + values
-                + " do not match expected error values: "
-                + expectedValues, values, expectedValues);
-    }
-
-    //expected erroneous tree: void m1(int i) {(ERROR);{(ERROR);}
-    public void testSwitchError() throws IOException {
-
-        String code = "package test; public class ErrorTest { "
-                + "int numDays; void m1(int i) { switchh {i} { case 1: "
-                + "numDays = 31; break; } } }";
-        CompilationUnitTree cut = getCompilationUnitTree(code);
-        final List<String> values = new ArrayList<>();
-        final List<String> expectedValues =
-                new ArrayList<>(Arrays.asList("[switchh]", "[i]"));
-
-        new TreeScanner<Void, Void>() {
-
-            @Override
-            public Void visitErroneous(ErroneousTree node, Void p) {
-
-                values.add(getErroneousTreeValues(node).toString());
-                return null;
-            }
-        }.scan(cut, null);
-
-        assertEquals("testSwitchError: The Erroneous tree "
-                + "error values: " + values
-                + " do not match expected error values: "
-                + expectedValues, values, expectedValues);
-    }
-
-    //expected erroneous tree: class ErrorTest {(ERROR)
-    public void testMethodError() throws IOException {
-
-        String code = "package Test; class ErrorTest {  "
-                + "static final void f) {String s = new String(); } }";
-        CompilationUnitTree cut = getCompilationUnitTree(code);
-        final List<String> values = new ArrayList<>();
-        final List<String> expectedValues =
-                new ArrayList<>(Arrays.asList("[\nstatic final void f();]"));
-
-        new TreeScanner<Void, Void>() {
-
-            @Override
-            public Void visitErroneous(ErroneousTree node, Void p) {
-
-                values.add(normalize(getErroneousTreeValues(node).toString()));
-                return null;
-            }
-        }.scan(cut, null);
-
-        assertEquals("testMethodError: The Erroneous tree "
-                + "error value: " + values
-                + " does not match expected error values: "
-                + expectedValues, values, expectedValues);
-    }
-
-    void testsNotWorking() throws IOException {
-
-        // Fails with nb-javac, needs further investigation
-        testPositionBrokenSource126732a();
-        testPositionBrokenSource126732b();
-
-        // Fails, these tests yet to be addressed
-        testPositionForEnumModifiers();
-        testStartPositionEnumConstantInit();
-    }
-    void testPositions() throws IOException {
-        testPositionsSane();
-        testCorrectWilcardPositions();
-        testPositionAnnotationNoPackage187551();
-        testPositionForSuperConstructorCalls();
-        testPreferredPositionForBinaryOp();
-        testStartPositionForMethodWithoutModifiers();
-        testVarPos();
-        testVariableInIfThen1();
-        testVariableInIfThen2();
-        testVariableInIfThen3();
-        testVariableInIfThen4();
-        testVariableInIfThen5();
-        testMissingExponent();
-        testTryResourcePos();
-        testOperatorMissingError();
-        testMissingParenthesisError();
-        testMissingClassError();
-        testSwitchError();
-        testMethodError();
-        testErrorRecoveryForEnhancedForLoop142381();
-    }
-
-    public static void main(String... args) throws IOException {
-        JavacParserTest jpt = new JavacParserTest("JavacParserTest");
-        jpt.testPositions();
-        System.out.println("PASS");
+        }
+        System.out.printf("Passed: %d, Failed %d%n", passed, failed);
+        if (failed > 0) {
+            throw new RuntimeException("Tests failed: " + failed);
+        }
+        if (passed == 0 && failed == 0) {
+            throw new AssertionError("No test(s) selected: passed = " +
+                    passed + ", failed = " + failed + " ??????????");
+        }
     }
 }
 
@@ -906,8 +947,6 @@
     }
 
     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);
         }
@@ -929,4 +968,11 @@
     void fail(String message) {
         throw new RuntimeException(message);
     }
+
+    /**
+     * Indicates that the annotated method is a test method.
+     */
+    @Retention(RetentionPolicy.RUNTIME)
+    @Target(ElementType.METHOD)
+    public @interface Test {}
 }
--- a/test/tools/javac/tree/DocCommentToplevelTest.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/tree/DocCommentToplevelTest.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -29,6 +29,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.*;
+import com.sun.tools.javac.tree.DocCommentTable;
 import com.sun.tools.javac.tree.JCTree;
 
 import java.net.URI;
@@ -137,16 +138,16 @@
 
         new TreeScanner<ClassTree,Void>() {
 
-            Map<JCTree, String> docComments;
+            DocCommentTable docComments;
 
             @Override
             public ClassTree visitCompilationUnit(CompilationUnitTree node, Void unused) {
                 docComments = ((JCTree.JCCompilationUnit)node).docComments;
                 boolean expectedComment = tdk == ToplevelDocKind.HAS_DOC &&
                         (pk != PackageKind.NO_PKG || ik != ImportKind.ZERO);
-                boolean foundComment = docComments.get(node) != null;
+                boolean foundComment = docComments.hasComment((JCTree) node);
                 if (expectedComment != foundComment) {
-                    error("Unexpected comment " + docComments.get(node) + " on toplevel");
+                    error("Unexpected comment " + docComments.getComment((JCTree) node) + " on toplevel");
                 }
                 return super.visitCompilationUnit(node, null);
             }
@@ -156,9 +157,9 @@
                 boolean expectedComment = tdk == ToplevelDocKind.HAS_DOC &&
                         pk == PackageKind.NO_PKG && ik == ImportKind.ZERO &&
                         node.getSimpleName().toString().equals("First");
-                boolean foundComment = docComments.get(node) != null;
+                boolean foundComment = docComments.hasComment((JCTree) node);
                 if (expectedComment != foundComment) {
-                    error("Unexpected comment " + docComments.get(node) + " on class " + node.getSimpleName());
+                    error("Unexpected comment " + docComments.getComment((JCTree) node) + " on class " + node.getSimpleName());
                 }
                 return super.visitClass(node, unused);
             }
--- a/test/tools/javac/tree/TreePosTest.java	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/tree/TreePosTest.java	Thu Aug 02 17:00:14 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@
 import com.sun.source.util.JavacTask;
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.code.Flags;
-import com.sun.tools.javac.parser.EndPosTable;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
 import com.sun.tools.javac.tree.JCTree.JCNewClass;
--- a/test/tools/javac/varargs/6313164/T6313164.out	Tue May 29 00:27:58 2012 +0100
+++ b/test/tools/javac/varargs/6313164/T6313164.out	Thu Aug 02 17:00:14 2012 +0100
@@ -1,6 +1,6 @@
 T6313164.java:12:8: compiler.err.cant.apply.symbol.1: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
-T6313164.java:14:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164))
-T6313164.java:15:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164))
+T6313164.java:14:13: compiler.err.cant.apply.symbol.1: kindname.method, foo3, X[], compiler.misc.type.null,compiler.misc.type.null, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
+T6313164.java:15:13: compiler.err.cant.apply.symbol.1: kindname.method, foo4, X[], compiler.misc.type.null,compiler.misc.type.null, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)
 - compiler.note.unchecked.filename: B.java
 - compiler.note.unchecked.recompile
 3 errors