Merge jdk8-b36

Mon, 23 Apr 2012 16:59:32 -0700

author
lana
date
Mon, 23 Apr 2012 16:59:32 -0700
changeset 1253
94bbaa67686f
parent 1247
068207a80397
parent 1252
d023d5c3fbd2
child 1254
5891b38985e8

Merge

test/tools/javac/diags/examples/InferredDoNotConformToBounds.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java	Thu Apr 19 12:19:06 2012 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java	Mon Apr 23 16:59:32 2012 -0700
     1.3 @@ -1147,29 +1147,6 @@
     1.4          }
     1.5  
     1.6          /**
     1.7 -         * Kind of type-constraint derived during type inference
     1.8 -         */
     1.9 -        public enum ConstraintKind {
    1.10 -            /**
    1.11 -             * upper bound constraint (a type variable must be instantiated
    1.12 -             * with a type T, where T is a subtype of all the types specified by
    1.13 -             * its EXTENDS constraints).
    1.14 -             */
    1.15 -            EXTENDS,
    1.16 -            /**
    1.17 -             * lower bound constraint (a type variable must be instantiated
    1.18 -             * with a type T, where T is a supertype of all the types specified by
    1.19 -             * its SUPER constraints).
    1.20 -             */
    1.21 -            SUPER,
    1.22 -            /**
    1.23 -             * equality constraint (a type variable must be instantiated to the type
    1.24 -             * specified by its EQUAL constraint.
    1.25 -             */
    1.26 -            EQUAL;
    1.27 -        }
    1.28 -
    1.29 -        /**
    1.30           * Get the type-constraints of a given kind for a given type-variable of
    1.31           * this ForAll type. Subclasses should override in order to return more
    1.32           * accurate sets of constraints.
    1.33 @@ -1178,7 +1155,7 @@
    1.34           * @param ck the constraint kind to be retrieved
    1.35           * @return the list of types specified by the selected constraint
    1.36           */
    1.37 -        public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
    1.38 +        public List<Type> undetvars() {
    1.39              return List.nil();
    1.40          }
    1.41  
    1.42 @@ -1220,6 +1197,7 @@
    1.43      public static class UndetVar extends DelegatedType {
    1.44          public List<Type> lobounds = List.nil();
    1.45          public List<Type> hibounds = List.nil();
    1.46 +        public List<Type> eq = List.nil();
    1.47          public Type inst = null;
    1.48  
    1.49          @Override
     2.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Thu Apr 19 12:19:06 2012 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Apr 23 16:59:32 2012 -0700
     2.3 @@ -326,11 +326,6 @@
     2.4              else if (t.tag == TYPEVAR) {
     2.5                  return isSubtypeUnchecked(t.getUpperBound(), s, warn);
     2.6              }
     2.7 -            else if (s.tag == UNDETVAR) {
     2.8 -                UndetVar uv = (UndetVar)s;
     2.9 -                if (uv.inst != null)
    2.10 -                    return isSubtypeUnchecked(t, uv.inst, warn);
    2.11 -            }
    2.12              else if (!s.isRaw()) {
    2.13                  Type t2 = asSuper(t, s.tsym);
    2.14                  if (t2 != null && t2.isRaw()) {
    2.15 @@ -515,9 +510,6 @@
    2.16                      return false;
    2.17                  }
    2.18  
    2.19 -                if (t.inst != null)
    2.20 -                    return isSubtypeNoCapture(t.inst, s); // TODO: ", warn"?
    2.21 -
    2.22                  t.hibounds = t.hibounds.prepend(s);
    2.23                  return true;
    2.24              }
    2.25 @@ -586,8 +578,6 @@
    2.26                  undet.qtype == s ||
    2.27                  s.tag == ERROR ||
    2.28                  s.tag == BOT) return true;
    2.29 -            if (undet.inst != null)
    2.30 -                return isSubtype(s, undet.inst);
    2.31              undet.lobounds = undet.lobounds.prepend(s);
    2.32              return true;
    2.33          }
    2.34 @@ -733,18 +723,8 @@
    2.35                  if (t == s || t.qtype == s || s.tag == ERROR || s.tag == UNKNOWN)
    2.36                      return true;
    2.37  
    2.38 -                if (t.inst != null)
    2.39 -                    return visit(t.inst, s);
    2.40 -
    2.41 -                t.inst = fromUnknownFun.apply(s);
    2.42 -                for (List<Type> l = t.lobounds; l.nonEmpty(); l = l.tail) {
    2.43 -                    if (!isSubtype(l.head, t.inst))
    2.44 -                        return false;
    2.45 -                }
    2.46 -                for (List<Type> l = t.hibounds; l.nonEmpty(); l = l.tail) {
    2.47 -                    if (!isSubtype(t.inst, l.head))
    2.48 -                        return false;
    2.49 -                }
    2.50 +                t.eq = t.eq.prepend(s);
    2.51 +
    2.52                  return true;
    2.53              }
    2.54  
    2.55 @@ -779,23 +759,11 @@
    2.56                      case UNBOUND: //similar to ? extends Object
    2.57                      case EXTENDS: {
    2.58                          Type bound = upperBound(s);
    2.59 -                        // We should check the new upper bound against any of the
    2.60 -                        // undetvar's lower bounds.
    2.61 -                        for (Type t2 : undetvar.lobounds) {
    2.62 -                            if (!isSubtype(t2, bound))
    2.63 -                                return false;
    2.64 -                        }
    2.65                          undetvar.hibounds = undetvar.hibounds.prepend(bound);
    2.66                          break;
    2.67                      }
    2.68                      case SUPER: {
    2.69                          Type bound = lowerBound(s);
    2.70 -                        // We should check the new lower bound against any of the
    2.71 -                        // undetvar's lower bounds.
    2.72 -                        for (Type t2 : undetvar.hibounds) {
    2.73 -                            if (!isSubtype(bound, t2))
    2.74 -                                return false;
    2.75 -                        }
    2.76                          undetvar.lobounds = undetvar.lobounds.prepend(bound);
    2.77                          break;
    2.78                      }
     3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Thu Apr 19 12:19:06 2012 -0700
     3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Apr 23 16:59:32 2012 -0700
     3.3 @@ -32,7 +32,6 @@
     3.4  import com.sun.tools.javac.util.List;
     3.5  import com.sun.tools.javac.code.*;
     3.6  import com.sun.tools.javac.code.Type.*;
     3.7 -import com.sun.tools.javac.code.Type.ForAll.ConstraintKind;
     3.8  import com.sun.tools.javac.code.Symbol.*;
     3.9  import com.sun.tools.javac.comp.Resolve.InapplicableMethodException;
    3.10  import com.sun.tools.javac.comp.Resolve.VerboseResolutionMode;
    3.11 @@ -122,84 +121,21 @@
    3.12  
    3.13      /** A mapping that turns type variables into undetermined type variables.
    3.14       */
    3.15 -    Mapping fromTypeVarFun = new Mapping("fromTypeVarFun") {
    3.16 -            public Type apply(Type t) {
    3.17 -                if (t.tag == TYPEVAR) return new UndetVar(t);
    3.18 -                else return t.map(this);
    3.19 -            }
    3.20 -        };
    3.21 -
    3.22 -    /** A mapping that returns its type argument with every UndetVar replaced
    3.23 -     *  by its `inst' field. Throws a NoInstanceException
    3.24 -     *  if this not possible because an `inst' field is null.
    3.25 -     *  Note: mutually referring undertvars will be left uninstantiated
    3.26 -     *  (that is, they will be replaced by the underlying type-variable).
    3.27 -     */
    3.28 -
    3.29 -    Mapping getInstFun = new Mapping("getInstFun") {
    3.30 -            public Type apply(Type t) {
    3.31 -                switch (t.tag) {
    3.32 -                    case UNKNOWN:
    3.33 -                        throw ambiguousNoInstanceException
    3.34 -                            .setMessage("undetermined.type");
    3.35 -                    case UNDETVAR:
    3.36 -                        UndetVar that = (UndetVar) t;
    3.37 -                        if (that.inst == null)
    3.38 -                            throw ambiguousNoInstanceException
    3.39 -                                .setMessage("type.variable.has.undetermined.type",
    3.40 -                                            that.qtype);
    3.41 -                        return isConstraintCyclic(that) ?
    3.42 -                            that.qtype :
    3.43 -                            apply(that.inst);
    3.44 -                        default:
    3.45 -                            return t.map(this);
    3.46 +    List<Type> makeUndetvars(List<Type> tvars) {
    3.47 +        List<Type> undetvars = Type.map(tvars, fromTypeVarFun);
    3.48 +        for (Type t : undetvars) {
    3.49 +            UndetVar uv = (UndetVar)t;
    3.50 +            uv.hibounds = types.getBounds((TypeVar)uv.qtype);
    3.51 +        }
    3.52 +        return undetvars;
    3.53 +    }
    3.54 +    //where
    3.55 +            Mapping fromTypeVarFun = new Mapping("fromTypeVarFun") {
    3.56 +                public Type apply(Type t) {
    3.57 +                    if (t.tag == TYPEVAR) return new UndetVar(t);
    3.58 +                    else return t.map(this);
    3.59                  }
    3.60 -            }
    3.61 -
    3.62 -            private boolean isConstraintCyclic(UndetVar uv) {
    3.63 -                Types.UnaryVisitor<Boolean> constraintScanner =
    3.64 -                        new Types.UnaryVisitor<Boolean>() {
    3.65 -
    3.66 -                    List<Type> seen = List.nil();
    3.67 -
    3.68 -                    Boolean visit(List<Type> ts) {
    3.69 -                        for (Type t : ts) {
    3.70 -                            if (visit(t)) return true;
    3.71 -                        }
    3.72 -                        return false;
    3.73 -                    }
    3.74 -
    3.75 -                    public Boolean visitType(Type t, Void ignored) {
    3.76 -                        return false;
    3.77 -                    }
    3.78 -
    3.79 -                    @Override
    3.80 -                    public Boolean visitClassType(ClassType t, Void ignored) {
    3.81 -                        if (t.isCompound()) {
    3.82 -                            return visit(types.supertype(t)) ||
    3.83 -                                    visit(types.interfaces(t));
    3.84 -                        } else {
    3.85 -                            return visit(t.getTypeArguments());
    3.86 -                        }
    3.87 -                    }
    3.88 -                    @Override
    3.89 -                    public Boolean visitWildcardType(WildcardType t, Void ignored) {
    3.90 -                        return visit(t.type);
    3.91 -                    }
    3.92 -
    3.93 -                    @Override
    3.94 -                    public Boolean visitUndetVar(UndetVar t, Void ignored) {
    3.95 -                        if (seen.contains(t)) {
    3.96 -                            return true;
    3.97 -                        } else {
    3.98 -                            seen = seen.prepend(t);
    3.99 -                            return visit(t.inst);
   3.100 -                        }
   3.101 -                    }
   3.102 -                };
   3.103 -                return constraintScanner.visit(uv);
   3.104 -            }
   3.105 -        };
   3.106 +            };
   3.107  
   3.108  /***************************************************************************
   3.109   * Mini/Maximization of UndetVars
   3.110 @@ -210,13 +146,15 @@
   3.111       */
   3.112      void maximizeInst(UndetVar that, Warner warn) throws NoInstanceException {
   3.113          List<Type> hibounds = Type.filter(that.hibounds, errorFilter);
   3.114 -        if (that.inst == null) {
   3.115 +        if (that.eq.isEmpty()) {
   3.116              if (hibounds.isEmpty())
   3.117                  that.inst = syms.objectType;
   3.118              else if (hibounds.tail.isEmpty())
   3.119                  that.inst = hibounds.head;
   3.120              else
   3.121                  that.inst = types.glb(hibounds);
   3.122 +        } else {
   3.123 +            that.inst = that.eq.head;
   3.124          }
   3.125          if (that.inst == null ||
   3.126              that.inst.isErroneous())
   3.127 @@ -224,27 +162,6 @@
   3.128                  .setMessage("no.unique.maximal.instance.exists",
   3.129                              that.qtype, hibounds);
   3.130      }
   3.131 -    //where
   3.132 -        private boolean isSubClass(Type t, final List<Type> ts) {
   3.133 -            t = t.baseType();
   3.134 -            if (t.tag == TYPEVAR) {
   3.135 -                List<Type> bounds = types.getBounds((TypeVar)t);
   3.136 -                for (Type s : ts) {
   3.137 -                    if (!types.isSameType(t, s.baseType())) {
   3.138 -                        for (Type bound : bounds) {
   3.139 -                            if (!isSubClass(bound, List.of(s.baseType())))
   3.140 -                                return false;
   3.141 -                        }
   3.142 -                    }
   3.143 -                }
   3.144 -            } else {
   3.145 -                for (Type s : ts) {
   3.146 -                    if (!t.tsym.isSubClass(s.baseType().tsym, types))
   3.147 -                        return false;
   3.148 -                }
   3.149 -            }
   3.150 -            return true;
   3.151 -        }
   3.152  
   3.153      private Filter<Type> errorFilter = new Filter<Type>() {
   3.154          @Override
   3.155 @@ -258,7 +175,7 @@
   3.156       */
   3.157      void minimizeInst(UndetVar that, Warner warn) throws NoInstanceException {
   3.158          List<Type> lobounds = Type.filter(that.lobounds, errorFilter);
   3.159 -        if (that.inst == null) {
   3.160 +        if (that.eq.isEmpty()) {
   3.161              if (lobounds.isEmpty())
   3.162                  that.inst = syms.botType;
   3.163              else if (lobounds.tail.isEmpty())
   3.164 @@ -270,21 +187,8 @@
   3.165                      throw ambiguousNoInstanceException
   3.166                          .setMessage("no.unique.minimal.instance.exists",
   3.167                                      that.qtype, lobounds);
   3.168 -            // VGJ: sort of inlined maximizeInst() below.  Adding
   3.169 -            // bounds can cause lobounds that are above hibounds.
   3.170 -            List<Type> hibounds = Type.filter(that.hibounds, errorFilter);
   3.171 -            Type hb = null;
   3.172 -            if (hibounds.isEmpty())
   3.173 -                hb = syms.objectType;
   3.174 -            else if (hibounds.tail.isEmpty())
   3.175 -                hb = hibounds.head;
   3.176 -            else
   3.177 -                hb = types.glb(hibounds);
   3.178 -            if (hb == null ||
   3.179 -                hb.isErroneous())
   3.180 -                throw ambiguousNoInstanceException
   3.181 -                        .setMessage("incompatible.upper.bounds",
   3.182 -                                    that.qtype, hibounds);
   3.183 +        } else {
   3.184 +            that.inst = that.eq.head;
   3.185          }
   3.186      }
   3.187  
   3.188 @@ -313,21 +217,7 @@
   3.189      public Type instantiateExpr(ForAll that,
   3.190                                  Type to,
   3.191                                  Warner warn) throws InferenceException {
   3.192 -        List<Type> undetvars = Type.map(that.tvars, fromTypeVarFun);
   3.193 -        for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) {
   3.194 -            UndetVar uv = (UndetVar) l.head;
   3.195 -            TypeVar tv = (TypeVar)uv.qtype;
   3.196 -            ListBuffer<Type> hibounds = new ListBuffer<Type>();
   3.197 -            for (Type t : that.getConstraints(tv, ConstraintKind.EXTENDS)) {
   3.198 -                hibounds.append(types.subst(t, that.tvars, undetvars));
   3.199 -            }
   3.200 -
   3.201 -            List<Type> inst = that.getConstraints(tv, ConstraintKind.EQUAL);
   3.202 -            if (inst.nonEmpty() && inst.head.tag != BOT) {
   3.203 -                uv.inst = inst.head;
   3.204 -            }
   3.205 -            uv.hibounds = hibounds.toList();
   3.206 -        }
   3.207 +        List<Type> undetvars = that.undetvars();
   3.208          Type qtype1 = types.subst(that.qtype, that.tvars, undetvars);
   3.209          if (!types.isSubtype(qtype1,
   3.210                  qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) {
   3.211 @@ -335,41 +225,72 @@
   3.212                  .setMessage("infer.no.conforming.instance.exists",
   3.213                              that.tvars, that.qtype, to);
   3.214          }
   3.215 -        for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail)
   3.216 -            maximizeInst((UndetVar) l.head, warn);
   3.217 -        // System.out.println(" = " + qtype1.map(getInstFun));//DEBUG
   3.218  
   3.219 -        // check bounds
   3.220 -        List<Type> targs = Type.map(undetvars, getInstFun);
   3.221 -        if (Type.containsAny(targs, that.tvars)) {
   3.222 -            //replace uninferred type-vars
   3.223 -            targs = types.subst(targs,
   3.224 +        List<Type> insttypes;
   3.225 +        while (true) {
   3.226 +            boolean stuck = true;
   3.227 +            insttypes = List.nil();
   3.228 +            for (Type t : undetvars) {
   3.229 +                UndetVar uv = (UndetVar)t;
   3.230 +                if (uv.inst == null && (uv.eq.nonEmpty() || !Type.containsAny(uv.hibounds, that.tvars))) {
   3.231 +                    maximizeInst((UndetVar)t, warn);
   3.232 +                    stuck = false;
   3.233 +                }
   3.234 +                insttypes = insttypes.append(uv.inst == null ? uv.qtype : uv.inst);
   3.235 +            }
   3.236 +            if (!Type.containsAny(insttypes, that.tvars)) {
   3.237 +                //all variables have been instantiated - exit
   3.238 +                break;
   3.239 +            } else if (stuck) {
   3.240 +                //some variables could not be instantiated because of cycles in
   3.241 +                //upper bounds - provide a (possibly recursive) default instantiation
   3.242 +                insttypes = types.subst(insttypes,
   3.243                      that.tvars,
   3.244                      instantiateAsUninferredVars(undetvars, that.tvars));
   3.245 +                break;
   3.246 +            } else {
   3.247 +                //some variables have been instantiated - replace newly instantiated
   3.248 +                //variables in remaining upper bounds and continue
   3.249 +                for (Type t : undetvars) {
   3.250 +                    UndetVar uv = (UndetVar)t;
   3.251 +                    uv.hibounds = types.subst(uv.hibounds, that.tvars, insttypes);
   3.252 +                }
   3.253 +            }
   3.254          }
   3.255 -        return that.inst(targs, types);
   3.256 +        return that.inst(insttypes, types);
   3.257      }
   3.258 -    //where
   3.259 +
   3.260 +    /**
   3.261 +     * Infer cyclic inference variables as described in 15.12.2.8.
   3.262 +     */
   3.263      private List<Type> instantiateAsUninferredVars(List<Type> undetvars, List<Type> tvars) {
   3.264          Assert.check(undetvars.length() == tvars.length());
   3.265 -        ListBuffer<Type> new_targs = ListBuffer.lb();
   3.266 -        //step 1 - create synthetic captured vars
   3.267 +        ListBuffer<Type> insttypes = ListBuffer.lb();
   3.268 +        ListBuffer<Type> todo = ListBuffer.lb();
   3.269 +        //step 1 - create fresh tvars
   3.270          for (Type t : undetvars) {
   3.271              UndetVar uv = (UndetVar)t;
   3.272 -            Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null);
   3.273 -            new_targs = new_targs.append(newArg);
   3.274 +            if (uv.inst == null) {
   3.275 +                TypeSymbol fresh_tvar = new TypeSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner);
   3.276 +                fresh_tvar.type = new TypeVar(fresh_tvar, types.makeCompoundType(uv.hibounds), null);
   3.277 +                todo.append(uv);
   3.278 +                uv.inst = fresh_tvar.type;
   3.279 +            }
   3.280 +            insttypes.append(uv.inst);
   3.281          }
   3.282 -        //step 2 - replace synthetic vars in their bounds
   3.283 +        //step 2 - replace fresh tvars in their bounds
   3.284          List<Type> formals = tvars;
   3.285 -        for (Type t : new_targs.toList()) {
   3.286 -            CapturedType ct = (CapturedType)t;
   3.287 -            ct.bound = types.subst(ct.bound, tvars, new_targs.toList());
   3.288 -            WildcardType wt = new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass);
   3.289 -            wt.bound = (TypeVar)formals.head;
   3.290 -            ct.wildcard = wt;
   3.291 +        for (Type t : todo) {
   3.292 +            UndetVar uv = (UndetVar)t;
   3.293 +            TypeVar ct = (TypeVar)uv.inst;
   3.294 +            ct.bound = types.glb(types.subst(types.getBounds(ct), tvars, insttypes.toList()));
   3.295 +            if (ct.bound.isErroneous()) {
   3.296 +                //report inference error if glb fails
   3.297 +                reportBoundError(uv, BoundErrorKind.BAD_UPPER);
   3.298 +            }
   3.299              formals = formals.tail;
   3.300          }
   3.301 -        return new_targs.toList();
   3.302 +        return insttypes.toList();
   3.303      }
   3.304  
   3.305      /** Instantiate method type `mt' by finding instantiations of
   3.306 @@ -384,7 +305,7 @@
   3.307                                    final boolean useVarargs,
   3.308                                    final Warner warn) throws InferenceException {
   3.309          //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG
   3.310 -        List<Type> undetvars = Type.map(tvars, fromTypeVarFun);
   3.311 +        final List<Type> undetvars =  makeUndetvars(tvars);
   3.312  
   3.313          final List<Type> capturedArgs =
   3.314                  rs.checkRawArgumentsAcceptable(env, undetvars, argtypes, mt.getParameterTypes(),
   3.315 @@ -419,7 +340,7 @@
   3.316                  undettypes.append(uv.inst);
   3.317              }
   3.318          }
   3.319 -        checkWithinBounds(tvars, undettypes.toList(), warn);
   3.320 +        checkWithinBounds(tvars, undetvars, insttypes.toList(), warn);
   3.321  
   3.322          mt = (MethodType)types.subst(mt, tvars, insttypes.toList());
   3.323  
   3.324 @@ -430,18 +351,8 @@
   3.325              final List<Type> all_tvars = tvars; //this is the wrong tvars
   3.326              return new UninferredMethodType(env.tree.pos(), msym, mt, restvars.toList()) {
   3.327                  @Override
   3.328 -                List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
   3.329 -                    for (Type t : restundet.toList()) {
   3.330 -                        UndetVar uv = (UndetVar)t;
   3.331 -                        if (uv.qtype == tv) {
   3.332 -                            switch (ck) {
   3.333 -                                case EXTENDS: return uv.hibounds.appendList(types.subst(types.getBounds(tv), all_tvars, inferredTypes));
   3.334 -                                case SUPER: return uv.lobounds;
   3.335 -                                case EQUAL: return uv.inst != null ? List.of(uv.inst) : List.<Type>nil();
   3.336 -                            }
   3.337 -                        }
   3.338 -                    }
   3.339 -                    return List.nil();
   3.340 +                List<Type> undetvars() {
   3.341 +                    return restundet.toList();
   3.342                  }
   3.343                  @Override
   3.344                  void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException {
   3.345 @@ -453,7 +364,7 @@
   3.346                      warn.clear();
   3.347                      checkArgumentsAcceptable(env, capturedArgs, owntype.getParameterTypes(), allowBoxing, useVarargs, warn);
   3.348                      // check that inferred bounds conform to their bounds
   3.349 -                    checkWithinBounds(all_tvars,
   3.350 +                    checkWithinBounds(all_tvars, undetvars,
   3.351                             types.subst(inferredTypes, tvars, inferred), warn);
   3.352                      qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs, warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED));
   3.353                  }
   3.354 @@ -525,7 +436,7 @@
   3.355  
   3.356              abstract void instantiateReturnType(Type restype, List<Type> inferred, Types types);
   3.357  
   3.358 -            abstract List<Type> getConstraints(TypeVar tv, ConstraintKind ck);
   3.359 +            abstract List<Type> undetvars();
   3.360  
   3.361              class UninferredReturnType extends ForAll {
   3.362                  public UninferredReturnType(List<Type> tvars, Type restype) {
   3.363 @@ -541,8 +452,8 @@
   3.364                      return UninferredMethodType.this.qtype.getReturnType();
   3.365                  }
   3.366                  @Override
   3.367 -                public List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
   3.368 -                    return UninferredMethodType.this.getConstraints(tv, ck);
   3.369 +                public List<Type> undetvars() {
   3.370 +                    return UninferredMethodType.this.undetvars();
   3.371                  }
   3.372              }
   3.373          }
   3.374 @@ -559,43 +470,94 @@
   3.375              }
   3.376          }
   3.377  
   3.378 -    /** Try to instantiate argument type `that' to given type `to'.
   3.379 -     *  If this fails, try to insantiate `that' to `to' where
   3.380 -     *  every occurrence of a type variable in `tvars' is replaced
   3.381 -     *  by an unknown type.
   3.382 +    /** check that type parameters are within their bounds.
   3.383       */
   3.384 -    private Type instantiateArg(ForAll that,
   3.385 -                                Type to,
   3.386 -                                List<Type> tvars,
   3.387 -                                Warner warn) throws InferenceException {
   3.388 -        List<Type> targs;
   3.389 -        try {
   3.390 -            return instantiateExpr(that, to, warn);
   3.391 -        } catch (NoInstanceException ex) {
   3.392 -            Type to1 = to;
   3.393 -            for (List<Type> l = tvars; l.nonEmpty(); l = l.tail)
   3.394 -                to1 = types.subst(to1, List.of(l.head), List.of(syms.unknownType));
   3.395 -            return instantiateExpr(that, to1, warn);
   3.396 +    void checkWithinBounds(List<Type> tvars,
   3.397 +                           List<Type> undetvars,
   3.398 +                           List<Type> arguments,
   3.399 +                           Warner warn)
   3.400 +        throws InvalidInstanceException {
   3.401 +        List<Type> args = arguments;
   3.402 +        for (Type t : undetvars) {
   3.403 +            UndetVar uv = (UndetVar)t;
   3.404 +            uv.hibounds = types.subst(uv.hibounds, tvars, arguments);
   3.405 +            uv.lobounds = types.subst(uv.lobounds, tvars, arguments);
   3.406 +            uv.eq = types.subst(uv.eq, tvars, arguments);
   3.407 +            checkCompatibleUpperBounds(uv, tvars);
   3.408 +            if (args.head.tag != TYPEVAR || !args.head.containsAny(tvars)) {
   3.409 +                Type inst = args.head;
   3.410 +                for (Type u : uv.hibounds) {
   3.411 +                    if (!types.isSubtypeUnchecked(inst, types.subst(u, tvars, undetvars), warn)) {
   3.412 +                        reportBoundError(uv, BoundErrorKind.UPPER);
   3.413 +                    }
   3.414 +                }
   3.415 +                for (Type l : uv.lobounds) {
   3.416 +                    if (!types.isSubtypeUnchecked(types.subst(l, tvars, undetvars), inst, warn)) {
   3.417 +                        reportBoundError(uv, BoundErrorKind.LOWER);
   3.418 +                    }
   3.419 +                }
   3.420 +                for (Type e : uv.eq) {
   3.421 +                    if (!types.isSameType(inst, types.subst(e, tvars, undetvars))) {
   3.422 +                        reportBoundError(uv, BoundErrorKind.EQ);
   3.423 +                    }
   3.424 +                }
   3.425 +            }
   3.426 +            args = args.tail;
   3.427          }
   3.428      }
   3.429  
   3.430 -    /** check that type parameters are within their bounds.
   3.431 -     */
   3.432 -    void checkWithinBounds(List<Type> tvars,
   3.433 -                                   List<Type> arguments,
   3.434 -                                   Warner warn)
   3.435 -        throws InvalidInstanceException {
   3.436 -        for (List<Type> tvs = tvars, args = arguments;
   3.437 -             tvs.nonEmpty();
   3.438 -             tvs = tvs.tail, args = args.tail) {
   3.439 -            if (args.head instanceof UndetVar ||
   3.440 -                    tvars.head.getUpperBound().isErroneous()) continue;
   3.441 -            List<Type> bounds = types.subst(types.getBounds((TypeVar)tvs.head), tvars, arguments);
   3.442 -            if (!types.isSubtypeUnchecked(args.head, bounds, warn))
   3.443 -                throw invalidInstanceException
   3.444 -                    .setMessage("inferred.do.not.conform.to.bounds",
   3.445 -                                args.head, bounds);
   3.446 +    void checkCompatibleUpperBounds(UndetVar uv, List<Type> tvars) {
   3.447 +        // VGJ: sort of inlined maximizeInst() below.  Adding
   3.448 +        // bounds can cause lobounds that are above hibounds.
   3.449 +        ListBuffer<Type> hiboundsNoVars = ListBuffer.lb();
   3.450 +        for (Type t : Type.filter(uv.hibounds, errorFilter)) {
   3.451 +            if (!t.containsAny(tvars)) {
   3.452 +                hiboundsNoVars.append(t);
   3.453 +            }
   3.454          }
   3.455 +        List<Type> hibounds = hiboundsNoVars.toList();
   3.456 +        Type hb = null;
   3.457 +        if (hibounds.isEmpty())
   3.458 +            hb = syms.objectType;
   3.459 +        else if (hibounds.tail.isEmpty())
   3.460 +            hb = hibounds.head;
   3.461 +        else
   3.462 +            hb = types.glb(hibounds);
   3.463 +        if (hb == null || hb.isErroneous())
   3.464 +            reportBoundError(uv, BoundErrorKind.BAD_UPPER);
   3.465 +    }
   3.466 +
   3.467 +    enum BoundErrorKind {
   3.468 +        BAD_UPPER() {
   3.469 +            @Override
   3.470 +            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
   3.471 +                return ex.setMessage("incompatible.upper.bounds", uv.qtype, uv.hibounds);
   3.472 +            }
   3.473 +        },
   3.474 +        UPPER() {
   3.475 +            @Override
   3.476 +            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
   3.477 +                return ex.setMessage("inferred.do.not.conform.to.upper.bounds", uv.inst, uv.hibounds);
   3.478 +            }
   3.479 +        },
   3.480 +        LOWER() {
   3.481 +            @Override
   3.482 +            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
   3.483 +                return ex.setMessage("inferred.do.not.conform.to.lower.bounds", uv.inst, uv.lobounds);
   3.484 +            }
   3.485 +        },
   3.486 +        EQ() {
   3.487 +            @Override
   3.488 +            InapplicableMethodException setMessage(InferenceException ex, UndetVar uv) {
   3.489 +                return ex.setMessage("inferred.do.not.conform.to.eq.bounds", uv.inst, uv.eq);
   3.490 +            }
   3.491 +        };
   3.492 +
   3.493 +        abstract InapplicableMethodException setMessage(InferenceException ex, UndetVar uv);
   3.494 +    }
   3.495 +    //where
   3.496 +    void reportBoundError(UndetVar uv, BoundErrorKind bk) {
   3.497 +        throw bk.setMessage(uv.inst == null ? ambiguousNoInstanceException : invalidInstanceException, uv);
   3.498      }
   3.499  
   3.500      /**
     4.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Thu Apr 19 12:19:06 2012 -0700
     4.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Mon Apr 23 16:59:32 2012 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  /*
     4.5 - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
     4.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
     4.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.8   *
     4.9   * This code is free software; you can redistribute it and/or modify it
    4.10 @@ -1798,92 +1798,126 @@
    4.11       */
    4.12      @SuppressWarnings("fallthrough")
    4.13      List<JCStatement> blockStatements() {
    4.14 -//todo: skip to anchor on error(?)
    4.15 -        int lastErrPos = -1;
    4.16 +        //todo: skip to anchor on error(?)
    4.17          ListBuffer<JCStatement> stats = new ListBuffer<JCStatement>();
    4.18          while (true) {
    4.19 -            int pos = token.pos;
    4.20 -            switch (token.kind) {
    4.21 -            case RBRACE: case CASE: case DEFAULT: case EOF:
    4.22 +            List<JCStatement> stat = blockStatement();
    4.23 +            if (stat.isEmpty()) {
    4.24                  return stats.toList();
    4.25 -            case LBRACE: case IF: case FOR: case WHILE: case DO: case TRY:
    4.26 -            case SWITCH: case SYNCHRONIZED: case RETURN: case THROW: case BREAK:
    4.27 -            case CONTINUE: case SEMI: case ELSE: case FINALLY: case CATCH:
    4.28 -                stats.append(parseStatement());
    4.29 +            } else {
    4.30 +                if (token.pos <= endPosTable.errorEndPos) {
    4.31 +                    skip(false, true, true, true);
    4.32 +                }
    4.33 +                stats.addAll(stat);
    4.34 +            }
    4.35 +        }
    4.36 +    }
    4.37 +
    4.38 +    /*
    4.39 +     * This method parses a statement treating it as a block, relaxing the
    4.40 +     * JLS restrictions, allows us to parse more faulty code, doing so
    4.41 +     * enables us to provide better and accurate diagnostics to the user.
    4.42 +     */
    4.43 +    JCStatement parseStatementAsBlock() {
    4.44 +        int pos = token.pos;
    4.45 +        List<JCStatement> stats = blockStatement();
    4.46 +        if (stats.isEmpty()) {
    4.47 +            JCErroneous e = F.at(pos).Erroneous();
    4.48 +            error(e, "illegal.start.of.stmt");
    4.49 +            return F.at(pos).Exec(e);
    4.50 +        } else {
    4.51 +            JCStatement first = stats.head;
    4.52 +            String error = null;
    4.53 +            switch (first.getTag()) {
    4.54 +            case CLASSDEF:
    4.55 +                error = "class.not.allowed";
    4.56                  break;
    4.57 -            case MONKEYS_AT:
    4.58 -            case FINAL: {
    4.59 -                String dc = token.comment(CommentStyle.JAVADOC);
    4.60 -                JCModifiers mods = modifiersOpt();
    4.61 -                if (token.kind == INTERFACE ||
    4.62 -                    token.kind == CLASS ||
    4.63 -                    allowEnums && token.kind == ENUM) {
    4.64 -                    stats.append(classOrInterfaceOrEnumDeclaration(mods, dc));
    4.65 -                } else {
    4.66 -                    JCExpression t = parseType();
    4.67 -                    stats.appendList(variableDeclarators(mods, t,
    4.68 -                                                         new ListBuffer<JCStatement>()));
    4.69 -                    // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
    4.70 -                    storeEnd(stats.elems.last(), token.endPos);
    4.71 -                    accept(SEMI);
    4.72 -                }
    4.73 +            case VARDEF:
    4.74 +                error = "variable.not.allowed";
    4.75                  break;
    4.76              }
    4.77 -            case ABSTRACT: case STRICTFP: {
    4.78 -                String dc = token.comment(CommentStyle.JAVADOC);
    4.79 -                JCModifiers mods = modifiersOpt();
    4.80 -                stats.append(classOrInterfaceOrEnumDeclaration(mods, dc));
    4.81 -                break;
    4.82 +            if (error != null) {
    4.83 +                error(first, error);
    4.84 +                List<JCBlock> blist = List.of(F.at(first.pos).Block(0, stats));
    4.85 +                return toP(F.at(pos).Exec(F.at(first.pos).Erroneous(blist)));
    4.86              }
    4.87 -            case INTERFACE:
    4.88 -            case CLASS:
    4.89 -                String dc = token.comment(CommentStyle.JAVADOC);
    4.90 -                stats.append(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
    4.91 -                break;
    4.92 -            case ENUM:
    4.93 -            case ASSERT:
    4.94 -                if (allowEnums && token.kind == ENUM) {
    4.95 -                    error(token.pos, "local.enum");
    4.96 -                    dc = token.comment(CommentStyle.JAVADOC);
    4.97 -                    stats.append(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
    4.98 -                    break;
    4.99 -                } else if (allowAsserts && token.kind == ASSERT) {
   4.100 -                    stats.append(parseStatement());
   4.101 -                    break;
   4.102 -                }
   4.103 -                /* fall through to default */
   4.104 -            default:
   4.105 -                Token prevToken = token;
   4.106 -                JCExpression t = term(EXPR | TYPE);
   4.107 -                if (token.kind == COLON && t.hasTag(IDENT)) {
   4.108 -                    nextToken();
   4.109 -                    JCStatement stat = parseStatement();
   4.110 -                    stats.append(F.at(pos).Labelled(prevToken.name(), stat));
   4.111 -                } else if ((lastmode & TYPE) != 0 &&
   4.112 -                           (token.kind == IDENTIFIER ||
   4.113 -                            token.kind == ASSERT ||
   4.114 -                            token.kind == ENUM)) {
   4.115 -                    pos = token.pos;
   4.116 -                    JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
   4.117 -                    F.at(pos);
   4.118 -                    stats.appendList(variableDeclarators(mods, t,
   4.119 -                                                         new ListBuffer<JCStatement>()));
   4.120 -                    // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
   4.121 -                    storeEnd(stats.elems.last(), token.endPos);
   4.122 -                    accept(SEMI);
   4.123 -                } else {
   4.124 -                    // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon
   4.125 -                    stats.append(to(F.at(pos).Exec(checkExprStat(t))));
   4.126 -                    accept(SEMI);
   4.127 -                }
   4.128 +            return first;
   4.129 +        }
   4.130 +    }
   4.131 +
   4.132 +    @SuppressWarnings("fallthrough")
   4.133 +    List<JCStatement> blockStatement() {
   4.134 +        //todo: skip to anchor on error(?)
   4.135 +        int pos = token.pos;
   4.136 +        switch (token.kind) {
   4.137 +        case RBRACE: case CASE: case DEFAULT: case EOF:
   4.138 +            return List.nil();
   4.139 +        case LBRACE: case IF: case FOR: case WHILE: case DO: case TRY:
   4.140 +        case SWITCH: case SYNCHRONIZED: case RETURN: case THROW: case BREAK:
   4.141 +        case CONTINUE: case SEMI: case ELSE: case FINALLY: case CATCH:
   4.142 +            return List.of(parseStatement());
   4.143 +        case MONKEYS_AT:
   4.144 +        case FINAL: {
   4.145 +            String dc = token.comment(CommentStyle.JAVADOC);
   4.146 +            JCModifiers mods = modifiersOpt();
   4.147 +            if (token.kind == INTERFACE ||
   4.148 +                token.kind == CLASS ||
   4.149 +                allowEnums && token.kind == ENUM) {
   4.150 +                return List.of(classOrInterfaceOrEnumDeclaration(mods, dc));
   4.151 +            } else {
   4.152 +                JCExpression t = parseType();
   4.153 +                ListBuffer<JCStatement> stats =
   4.154 +                        variableDeclarators(mods, t, new ListBuffer<JCStatement>());
   4.155 +                // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
   4.156 +                storeEnd(stats.elems.last(), token.endPos);
   4.157 +                accept(SEMI);
   4.158 +                return stats.toList();
   4.159              }
   4.160 -
   4.161 -            // error recovery
   4.162 -            if (token.pos == lastErrPos)
   4.163 +        }
   4.164 +        case ABSTRACT: case STRICTFP: {
   4.165 +            String dc = token.comment(CommentStyle.JAVADOC);
   4.166 +            JCModifiers mods = modifiersOpt();
   4.167 +            return List.of(classOrInterfaceOrEnumDeclaration(mods, dc));
   4.168 +        }
   4.169 +        case INTERFACE:
   4.170 +        case CLASS:
   4.171 +            String dc = token.comment(CommentStyle.JAVADOC);
   4.172 +            return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
   4.173 +        case ENUM:
   4.174 +        case ASSERT:
   4.175 +            if (allowEnums && token.kind == ENUM) {
   4.176 +                error(token.pos, "local.enum");
   4.177 +                dc = token.comment(CommentStyle.JAVADOC);
   4.178 +                return List.of(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc));
   4.179 +            } else if (allowAsserts && token.kind == ASSERT) {
   4.180 +                return List.of(parseStatement());
   4.181 +            }
   4.182 +            /* fall through to default */
   4.183 +        default:
   4.184 +            Token prevToken = token;
   4.185 +            JCExpression t = term(EXPR | TYPE);
   4.186 +            if (token.kind == COLON && t.hasTag(IDENT)) {
   4.187 +                nextToken();
   4.188 +                JCStatement stat = parseStatement();
   4.189 +                return List.<JCStatement>of(F.at(pos).Labelled(prevToken.name(), stat));
   4.190 +            } else if ((lastmode & TYPE) != 0 &&
   4.191 +                       (token.kind == IDENTIFIER ||
   4.192 +                        token.kind == ASSERT ||
   4.193 +                        token.kind == ENUM)) {
   4.194 +                pos = token.pos;
   4.195 +                JCModifiers mods = F.at(Position.NOPOS).Modifiers(0);
   4.196 +                F.at(pos);
   4.197 +                ListBuffer<JCStatement> stats =
   4.198 +                        variableDeclarators(mods, t, new ListBuffer<JCStatement>());
   4.199 +                // A "LocalVariableDeclarationStatement" subsumes the terminating semicolon
   4.200 +                storeEnd(stats.elems.last(), token.endPos);
   4.201 +                accept(SEMI);
   4.202                  return stats.toList();
   4.203 -            if (token.pos <= endPosTable.errorEndPos) {
   4.204 -                skip(false, true, true, true);
   4.205 -                lastErrPos = token.pos;
   4.206 +            } else {
   4.207 +                // This Exec is an "ExpressionStatement"; it subsumes the terminating semicolon
   4.208 +                JCExpressionStatement expr = to(F.at(pos).Exec(checkExprStat(t)));
   4.209 +                accept(SEMI);
   4.210 +                return List.<JCStatement>of(expr);
   4.211              }
   4.212          }
   4.213      }
   4.214 @@ -1917,11 +1951,11 @@
   4.215          case IF: {
   4.216              nextToken();
   4.217              JCExpression cond = parExpression();
   4.218 -            JCStatement thenpart = parseStatement();
   4.219 +            JCStatement thenpart = parseStatementAsBlock();
   4.220              JCStatement elsepart = null;
   4.221              if (token.kind == ELSE) {
   4.222                  nextToken();
   4.223 -                elsepart = parseStatement();
   4.224 +                elsepart = parseStatementAsBlock();
   4.225              }
   4.226              return F.at(pos).If(cond, thenpart, elsepart);
   4.227          }
   4.228 @@ -1938,7 +1972,7 @@
   4.229                  accept(COLON);
   4.230                  JCExpression expr = parseExpression();
   4.231                  accept(RPAREN);
   4.232 -                JCStatement body = parseStatement();
   4.233 +                JCStatement body = parseStatementAsBlock();
   4.234                  return F.at(pos).ForeachLoop(var, expr, body);
   4.235              } else {
   4.236                  accept(SEMI);
   4.237 @@ -1946,19 +1980,19 @@
   4.238                  accept(SEMI);
   4.239                  List<JCExpressionStatement> steps = token.kind == RPAREN ? List.<JCExpressionStatement>nil() : forUpdate();
   4.240                  accept(RPAREN);
   4.241 -                JCStatement body = parseStatement();
   4.242 +                JCStatement body = parseStatementAsBlock();
   4.243                  return F.at(pos).ForLoop(inits, cond, steps, body);
   4.244              }
   4.245          }
   4.246          case WHILE: {
   4.247              nextToken();
   4.248              JCExpression cond = parExpression();
   4.249 -            JCStatement body = parseStatement();
   4.250 +            JCStatement body = parseStatementAsBlock();
   4.251              return F.at(pos).WhileLoop(cond, body);
   4.252          }
   4.253          case DO: {
   4.254              nextToken();
   4.255 -            JCStatement body = parseStatement();
   4.256 +            JCStatement body = parseStatementAsBlock();
   4.257              accept(WHILE);
   4.258              JCExpression cond = parExpression();
   4.259              JCDoWhileLoop t = to(F.at(pos).DoLoop(body, cond));
     5.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Thu Apr 19 12:19:06 2012 -0700
     5.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Apr 23 16:59:32 2012 -0700
     5.3 @@ -196,6 +196,9 @@
     5.4  compiler.err.clash.with.pkg.of.same.name=\
     5.5      {0} {1} clashes with package of same name
     5.6  
     5.7 +compiler.err.class.not.allowed=\
     5.8 +    class, interface or enum declaration not allowed here
     5.9 +
    5.10  compiler.err.const.expr.req=\
    5.11      constant expression required
    5.12  
    5.13 @@ -385,6 +388,9 @@
    5.14  compiler.err.illegal.start.of.expr=\
    5.15      illegal start of expression
    5.16  
    5.17 +compiler.err.illegal.start.of.stmt=\
    5.18 +    illegal start of statement
    5.19 +
    5.20  compiler.err.illegal.start.of.type=\
    5.21      illegal start of type
    5.22  
    5.23 @@ -446,6 +452,9 @@
    5.24  compiler.err.varargs.and.old.array.syntax=\
    5.25      legacy array notation not allowed on variable-arity parameter
    5.26  
    5.27 +compiler.err.variable.not.allowed=\
    5.28 +    variable declaration not allowed here
    5.29 +
    5.30  # 0: name
    5.31  compiler.err.label.already.in.use=\
    5.32      label {0} already in use
    5.33 @@ -1574,9 +1583,6 @@
    5.34      cannot infer type arguments for {0}\n\
    5.35      reason: {1}
    5.36  
    5.37 -compiler.misc.type.variable.has.undetermined.type=\
    5.38 -    type variable {0} has undetermined type
    5.39 -
    5.40  # 0: type, 1: list of type
    5.41  compiler.misc.no.unique.maximal.instance.exists=\
    5.42      no unique maximal instance exists for type variable {0} with upper bounds {1}
    5.43 @@ -1604,10 +1610,22 @@
    5.44      no instance(s) of type variable(s) {0} exist so that argument type {1} conforms to vararg element type {2}
    5.45  
    5.46  # 0: type, 1: list of type
    5.47 -compiler.misc.inferred.do.not.conform.to.bounds=\
    5.48 -    inferred type does not conform to declared bound(s)\n\
    5.49 +compiler.misc.inferred.do.not.conform.to.upper.bounds=\
    5.50 +    inferred type does not conform to upper bound(s)\n\
    5.51      inferred: {0}\n\
    5.52 -    bound(s): {1}
    5.53 +    upper bound(s): {1}
    5.54 +
    5.55 +# 0: type, 1: list of type
    5.56 +compiler.misc.inferred.do.not.conform.to.lower.bounds=\
    5.57 +    inferred type does not conform to lower bound(s)\n\
    5.58 +    inferred: {0}\n\
    5.59 +    lower bound(s): {1}
    5.60 +
    5.61 +# 0: type, 1: list of type
    5.62 +compiler.misc.inferred.do.not.conform.to.eq.bounds=\
    5.63 +    inferred type does not conform to equality constraint(s)\n\
    5.64 +    inferred: {0}\n\
    5.65 +    equality constraints(s): {1}
    5.66  
    5.67  # 0: symbol
    5.68  compiler.misc.diamond=\
    5.69 @@ -2033,9 +2051,16 @@
    5.70  
    5.71  # compact where clause for type variable: contains the kindname ({2}) and location ({3})
    5.72  # in which the typevar has been declared
    5.73 +# 0: type, 1: list of type, 2: symbol kind, 3: symbol
    5.74  compiler.misc.where.typevar.1=\
    5.75      {0} declared in {2} {3}
    5.76  
    5.77 +# where clause for fresh type variable: contains upper bound(s) ('extends {1}').
    5.78 +# Since a fresh type-variable is synthetic - there's no location/kindname here.
    5.79 +# 0: type, 1: list of type
    5.80 +compiler.misc.where.fresh.typevar=\
    5.81 +    {0} extends {1}
    5.82 +
    5.83  # where clause for type variable: contains all the upper bound(s) ('extends {1}')
    5.84  # of this intersection type
    5.85  # 0: type, 1: list of type
     6.1 --- a/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Thu Apr 19 12:19:06 2012 -0700
     6.2 +++ b/src/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java	Mon Apr 23 16:59:32 2012 -0700
     6.3 @@ -540,13 +540,22 @@
     6.4                                           bounds.head.tag == NONE ||
     6.5                                           bounds.head.tag == ERROR;
     6.6  
     6.7 -
     6.8 -                JCDiagnostic d = diags.fragment("where.typevar" +
     6.9 +                if ((t.tsym.flags() & SYNTHETIC) == 0) {
    6.10 +                    //this is a true typevar
    6.11 +                    JCDiagnostic d = diags.fragment("where.typevar" +
    6.12                          (boundErroneous ? ".1" : ""), t, bounds,
    6.13                          Kinds.kindName(t.tsym.location()), t.tsym.location());
    6.14 -                whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d);
    6.15 -                symbolPreprocessor.visit(t.tsym.location(), null);
    6.16 -                visit(bounds);
    6.17 +                    whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d);
    6.18 +                    symbolPreprocessor.visit(t.tsym.location(), null);
    6.19 +                    visit(bounds);
    6.20 +                } else {
    6.21 +                    Assert.check(!boundErroneous);
    6.22 +                    //this is a fresh (synthetic) tvar
    6.23 +                    JCDiagnostic d = diags.fragment("where.fresh.typevar", t, bounds);
    6.24 +                    whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d);
    6.25 +                    visit(bounds);
    6.26 +                }
    6.27 +
    6.28              }
    6.29              return null;
    6.30          }
     7.1 --- a/test/tools/javac/Diagnostics/6722234/T6722234b_1.out	Thu Apr 19 12:19:06 2012 -0700
     7.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_1.out	Mon Apr 23 16:59:32 2012 -0700
     7.3 @@ -1,2 +1,2 @@
     7.4 -T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.type.captureof: 2, ? extends T6722234b>, List<T>)
     7.5 +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.type.captureof: 1, ? extends T6722234b>,List<compiler.misc.type.captureof: 2, ? extends T6722234b>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ? extends T6722234b, compiler.misc.type.captureof: 2, ? extends T6722234b,compiler.misc.type.captureof: 1, ? extends T6722234b)
     7.6  1 error
     8.1 --- a/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Thu Apr 19 12:19:06 2012 -0700
     8.2 +++ b/test/tools/javac/Diagnostics/6722234/T6722234b_2.out	Mon Apr 23 16:59:32 2012 -0700
     8.3 @@ -1,4 +1,4 @@
     8.4 -T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.infer.no.conforming.assignment.exists: T, List<compiler.misc.captured.type: 2>, List<T>)
     8.5 +T6722234b.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, List<T>,List<T>, List<compiler.misc.captured.type: 1>,List<compiler.misc.captured.type: 2>, kindname.class, T6722234b, (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.captured.type: 2, compiler.misc.captured.type: 2,compiler.misc.captured.type: 1)
     8.6  - compiler.misc.where.description.typevar: T,{(compiler.misc.where.typevar: T, Object, kindname.method, <T>m(List<T>,List<T>))}
     8.7  - compiler.misc.where.description.captured.1: compiler.misc.captured.type: 1,compiler.misc.captured.type: 2,{(compiler.misc.where.captured.1: compiler.misc.captured.type: 1, T6722234b, compiler.misc.type.null, ? extends T6722234b),(compiler.misc.where.captured.1: compiler.misc.captured.type: 2, T6722234b, compiler.misc.type.null, ? extends T6722234b)}
     8.8  1 error
     9.1 --- a/test/tools/javac/Diagnostics/6799605/T6799605.out	Thu Apr 19 12:19:06 2012 -0700
     9.2 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.out	Mon Apr 23 16:59:32 2012 -0700
     9.3 @@ -1,4 +1,4 @@
     9.4 -T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.inferred.do.not.conform.to.bounds: compiler.misc.type.captureof: 1, ?, T6799605<compiler.misc.type.captureof: 1, ?>))}
     9.5 -T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type.captureof: 2, ?>, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))}
     9.6 -T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.no.conforming.assignment.exists: T, T6799605<compiler.misc.type.captureof: 2, ?>, T6799605<T>)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))}
     9.7 +T6799605.java:17:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.inferred.do.not.conform.to.upper.bounds: compiler.misc.type.captureof: 1, ?, T6799605<compiler.misc.type.captureof: 1, ?>))}
     9.8 +T6799605.java:18:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 2, ?, compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))}
     9.9 +T6799605.java:19:9: compiler.err.cant.apply.symbols: kindname.method, m, T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>,{(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>,T6799605<T>), (compiler.misc.inferred.do.not.conform.to.eq.bounds: compiler.misc.type.captureof: 3, ?, compiler.misc.type.captureof: 3, ?,compiler.misc.type.captureof: 2, ?,compiler.misc.type.captureof: 1, ?)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>,T6799605<T>), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T6799605, <T>m(T6799605<T>), (compiler.misc.infer.arg.length.mismatch))}
    9.10  3 errors
    10.1 --- a/test/tools/javac/cast/7123100/T7123100a.out	Thu Apr 19 12:19:06 2012 -0700
    10.2 +++ b/test/tools/javac/cast/7123100/T7123100a.out	Mon Apr 23 16:59:32 2012 -0700
    10.3 @@ -1,4 +1,4 @@
    10.4 -T7123100a.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), compiler.misc.type.captureof: 1, ?, Z
    10.5 +T7123100a.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), E, Z
    10.6  - compiler.err.warnings.and.werror
    10.7  1 error
    10.8  1 warning
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/tools/javac/classfiles/ClassVersionChecker.java	Mon Apr 23 16:59:32 2012 -0700
    11.3 @@ -0,0 +1,149 @@
    11.4 +/*
    11.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + */
   11.26 +
   11.27 +/*
   11.28 + * @test
   11.29 + * @bug 7157626
   11.30 + * @summary Test major version for all legal combinations for -source and -target
   11.31 + * @author sgoel
   11.32 + *
   11.33 + */
   11.34 +
   11.35 +import java.io.*;
   11.36 +import java.nio.*;
   11.37 +import java.util.*;
   11.38 +import java.util.regex.*;
   11.39 +
   11.40 +public class ClassVersionChecker {
   11.41 +
   11.42 +    int errors;
   11.43 +    String[] jdk = {"","1.2","1.3","1.4","1.5","1.6","1.7","1.8"};
   11.44 +    File javaFile = null;
   11.45 +
   11.46 +    public static void main(String[] args) throws Throwable {
   11.47 +        new ClassVersionChecker().run();
   11.48 +    }
   11.49 +
   11.50 +    void run() throws Exception {
   11.51 +        writeTestFile();
   11.52 +        /* Rules applicable for -source and -target combinations
   11.53 +         * 1. If both empty, version num is for 1.7
   11.54 +         * 2. If source is not empty and target is empty, version is based on source
   11.55 +         * 3. If both non-empty, version is based on target
   11.56 +         */
   11.57 +
   11.58 +        /* -source (0=>empty,1=>1.2,...) X -target (0=>empty,1=>1.2,...)
   11.59 +         * ver[0][0] => no -source or -target was given
   11.60 +         * -1 => invalid combinations
   11.61 +         */
   11.62 +        int[][] ver =
   11.63 +                {{51, -1, -1, -1, -1, -1, -1, -1},
   11.64 +                 {48, 46, 47, 48, 49, 50, 51, 51},
   11.65 +                 {48, 46, 47, 48, 49, 50, 51, 51},
   11.66 +                 {48, -1, -1, 48, 49, 50, 51, 51},
   11.67 +                 {51, -1, -1, -1, 49, 50, 51, 51},
   11.68 +                 {51, -1, -1, -1, -1, 50, 51, 51},
   11.69 +                 {51, -1, -1, -1, -1, -1, 51, 51},
   11.70 +                 {51, -1, -1, -1, -1, -1, -1, 51}};
   11.71 +
   11.72 +        // Loop to run all possible combinations of source/target values
   11.73 +        for (int i = 0; i< ver.length; i++) {
   11.74 +            for (int j = 0 ; j< ver[i].length; j++) {
   11.75 +                if(ver[i][j] != -1) {
   11.76 +                    logMsg("Index values for i = " + i + " j = " + j);
   11.77 +                    logMsg("Running for src = " + jdk[i] + " target = "+jdk[j] +" expected = " + ver[i][j]);
   11.78 +                    test(i,j, ver[i][j]);
   11.79 +                }
   11.80 +            }
   11.81 +        }
   11.82 +
   11.83 +        if (errors > 0)
   11.84 +            throw new Exception(errors + " errors found");
   11.85 +    }
   11.86 +
   11.87 +    void test (int i, int j, int expected) {
   11.88 +        File classFile = compileTestFile(i, j, javaFile);
   11.89 +        short majorVer = getMajorVersion(classFile);
   11.90 +        checkVersion(majorVer, expected);
   11.91 +    }
   11.92 +
   11.93 +    void writeTestFile() throws IOException {
   11.94 +        javaFile = new File("Test.java");
   11.95 +        try(PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(javaFile)));) {
   11.96 +            out.println("class Test { ");
   11.97 +            out.println("  public void foo() { }");
   11.98 +            out.println("}");
   11.99 +        } catch (IOException ioe) {
  11.100 +            error("IOException while creating Test.java" + ioe);
  11.101 +        }
  11.102 +    }
  11.103 +
  11.104 +    File compileTestFile(int i , int j, File f) {
  11.105 +        int rc = -1;
  11.106 +        // Src and target are empty
  11.107 +        if (i == 0 && j == 0 ) {
  11.108 +            rc = compile("-g", f.getPath());
  11.109 +        } else if( j == 0 ) {  // target is empty
  11.110 +            rc = compile("-source", jdk[i], "-g", f.getPath());
  11.111 +        } else {
  11.112 +            rc = compile("-source", jdk[i], "-target", jdk[j], "-g", f.getPath());
  11.113 +        }
  11.114 +        if (rc != 0)
  11.115 +            throw new Error("compilation failed. rc=" + rc);
  11.116 +        String path = f.getPath();
  11.117 +        return new File(path.substring(0, path.length() - 5) + ".class");
  11.118 +    }
  11.119 +
  11.120 +    int compile(String... args) {
  11.121 +        return com.sun.tools.javac.Main.compile(args);
  11.122 +    }
  11.123 +
  11.124 +    void logMsg (String str) {
  11.125 +        System.out.println(str);
  11.126 +    }
  11.127 +
  11.128 +    short getMajorVersion(File f) {
  11.129 +        List<String> args = new ArrayList<String>();
  11.130 +        short majorVer = 0;
  11.131 +        try(DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(f)));) {
  11.132 +            in.readInt();
  11.133 +            in.readShort();
  11.134 +            majorVer = in.readShort();
  11.135 +            System.out.println("major version:" +  majorVer);
  11.136 +        } catch (IOException e) {
  11.137 +            error("IOException while reading Test.class" + e);
  11.138 +        }
  11.139 +        return majorVer;
  11.140 +    }
  11.141 +
  11.142 +    void checkVersion(short majorVer, int expected) {
  11.143 +        if (majorVer != expected ) {
  11.144 +            error("versions did not match, Expected: " + expected + "Got: " + majorVer);
  11.145 +        }
  11.146 +    }
  11.147 +
  11.148 +    void error(String msg) {
  11.149 +       System.out.println("error: " + msg);
  11.150 +       errors++;
  11.151 +    }
  11.152 +}
    12.1 --- a/test/tools/javac/diags/examples.not-yet.txt	Thu Apr 19 12:19:06 2012 -0700
    12.2 +++ b/test/tools/javac/diags/examples.not-yet.txt	Mon Apr 23 16:59:32 2012 -0700
    12.3 @@ -78,7 +78,6 @@
    12.4  compiler.misc.type.captureof.1
    12.5  compiler.misc.type.none
    12.6  compiler.misc.type.req.exact
    12.7 -compiler.misc.type.variable.has.undetermined.type
    12.8  compiler.misc.unable.to.access.file                     # ClassFile
    12.9  compiler.misc.undecl.type.var                           # ClassReader
   12.10  compiler.misc.unicode.str.not.supported                 # ClassReader
    13.1 --- a/test/tools/javac/diags/examples/CantApplyDiamond1.java	Thu Apr 19 12:19:06 2012 -0700
    13.2 +++ b/test/tools/javac/diags/examples/CantApplyDiamond1.java	Mon Apr 23 16:59:32 2012 -0700
    13.3 @@ -23,7 +23,7 @@
    13.4  
    13.5  // key: compiler.err.prob.found.req.1
    13.6  // key: compiler.misc.cant.apply.diamond.1
    13.7 -// key: compiler.misc.infer.no.conforming.instance.exists
    13.8 +// key: compiler.misc.no.conforming.assignment.exists
    13.9  // key: compiler.misc.diamond
   13.10  
   13.11  class CantApplyDiamond1<X> {
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/tools/javac/diags/examples/IllegalStartOfStmt.java	Mon Apr 23 16:59:32 2012 -0700
    14.3 @@ -0,0 +1,31 @@
    14.4 +/*
    14.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + */
   14.26 +
   14.27 +// key: compiler.err.illegal.start.of.stmt
   14.28 +// key: compiler.err.expected3
   14.29 +
   14.30 +class IllegalStartOfStmt {
   14.31 +    void m() {
   14.32 +        if (true) }
   14.33 +    }
   14.34 +}
    15.1 --- a/test/tools/javac/diags/examples/IncompatibleTypes1.java	Thu Apr 19 12:19:06 2012 -0700
    15.2 +++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java	Mon Apr 23 16:59:32 2012 -0700
    15.3 @@ -25,9 +25,9 @@
    15.4  // key: compiler.err.prob.found.req.1
    15.5  
    15.6  class IncompatibleTypes1<V> {
    15.7 -    <T extends Integer & Runnable> IncompatibleTypes1<T> m() {
    15.8 +    <T> IncompatibleTypes1<Integer> m() {
    15.9          return null;
   15.10      }
   15.11  
   15.12 -    IncompatibleTypes1<? super String> o = m();
   15.13 +    IncompatibleTypes1<? extends String> o = m();
   15.14  }
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/tools/javac/diags/examples/InferNoConformingAssignment.java	Mon Apr 23 16:59:32 2012 -0700
    16.3 @@ -0,0 +1,33 @@
    16.4 +/*
    16.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + *
    16.8 + * This code is free software; you can redistribute it and/or modify it
    16.9 + * under the terms of the GNU General Public License version 2 only, as
   16.10 + * published by the Free Software Foundation.
   16.11 + *
   16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 + * version 2 for more details (a copy is included in the LICENSE file that
   16.16 + * accompanied this code).
   16.17 + *
   16.18 + * You should have received a copy of the GNU General Public License version
   16.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 + *
   16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.23 + * or visit www.oracle.com if you need additional information or have any
   16.24 + * questions.
   16.25 + */
   16.26 +
   16.27 +// key: compiler.err.cant.apply.symbol.1
   16.28 +// key: compiler.misc.infer.no.conforming.assignment.exists
   16.29 +
   16.30 +import java.util.*;
   16.31 +
   16.32 +class InferNoConformingAssignment {
   16.33 +    <X extends Number> List<X> m(String s) { return null; }
   16.34 +    { this.m(1); }
   16.35 +}
   16.36 +
    17.1 --- a/test/tools/javac/diags/examples/InferredDoNotConformToBounds.java	Thu Apr 19 12:19:06 2012 -0700
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,35 +0,0 @@
    17.4 -/*
    17.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    17.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 - *
    17.8 - * This code is free software; you can redistribute it and/or modify it
    17.9 - * under the terms of the GNU General Public License version 2 only, as
   17.10 - * published by the Free Software Foundation.
   17.11 - *
   17.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 - * version 2 for more details (a copy is included in the LICENSE file that
   17.16 - * accompanied this code).
   17.17 - *
   17.18 - * You should have received a copy of the GNU General Public License version
   17.19 - * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 - *
   17.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.23 - * or visit www.oracle.com if you need additional information or have any
   17.24 - * questions.
   17.25 - */
   17.26 -
   17.27 -// key: compiler.misc.inferred.do.not.conform.to.bounds
   17.28 -// key: compiler.err.cant.apply.diamond.1
   17.29 -// key: compiler.misc.diamond
   17.30 -
   17.31 -class InferredDoNotConformToBounds {
   17.32 -   static class SuperFoo<X> {}
   17.33 -   static class Foo<X extends Number> extends SuperFoo<X> {
   17.34 -       Foo(X x) {}
   17.35 -   }
   17.36 -
   17.37 -   SuperFoo<String> sf1 = new Foo<>("");
   17.38 -}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/tools/javac/diags/examples/InferredDoNotConformToEq.java	Mon Apr 23 16:59:32 2012 -0700
    18.3 @@ -0,0 +1,32 @@
    18.4 +/*
    18.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + */
   18.26 +
   18.27 +// key: compiler.err.cant.apply.symbol.1
   18.28 +// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
   18.29 +
   18.30 +import java.util.*;
   18.31 +
   18.32 +class InferredDoNotConformToEq {
   18.33 +    <X> void m(List<X> lx1, List<X> lx2) {}
   18.34 +    { this.m(Arrays.asList(""), Arrays.asList(1)); }
   18.35 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/tools/javac/diags/examples/InferredDoNotConformToLower.java	Mon Apr 23 16:59:32 2012 -0700
    19.3 @@ -0,0 +1,33 @@
    19.4 +/*
    19.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +
   19.27 +// key: compiler.misc.invalid.inferred.types
   19.28 +// key: compiler.err.prob.found.req.1
   19.29 +// key: compiler.misc.inferred.do.not.conform.to.lower.bounds
   19.30 +
   19.31 +import java.util.*;
   19.32 +
   19.33 +class InferredDoNotConformToLower {
   19.34 +    <X extends Number> List<X> m() { return null; }
   19.35 +    { List<? super String> lss = this.m(); }
   19.36 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/tools/javac/diags/examples/InferredDoNotConformToUpper.java	Mon Apr 23 16:59:32 2012 -0700
    20.3 @@ -0,0 +1,32 @@
    20.4 +/*
    20.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + *
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + *
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + *
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + *
   20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 + * or visit www.oracle.com if you need additional information or have any
   20.24 + * questions.
   20.25 + */
   20.26 +
   20.27 +// key: compiler.err.cant.apply.symbol.1
   20.28 +// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
   20.29 +
   20.30 +import java.util.*;
   20.31 +
   20.32 +class InferredDoNotConformToUpper {
   20.33 +    <X> void m(X x, List<? super X> lx) {}
   20.34 +    { this.m("", Arrays.asList(1)); }
   20.35 +}
    21.1 --- a/test/tools/javac/diags/examples/InvalidInferredTypes.java	Thu Apr 19 12:19:06 2012 -0700
    21.2 +++ b/test/tools/javac/diags/examples/InvalidInferredTypes.java	Mon Apr 23 16:59:32 2012 -0700
    21.3 @@ -1,5 +1,5 @@
    21.4  /*
    21.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
    21.6 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
    21.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.8   *
    21.9   * This code is free software; you can redistribute it and/or modify it
   21.10 @@ -23,17 +23,15 @@
   21.11  
   21.12  // key: compiler.err.prob.found.req.1
   21.13  // key: compiler.misc.invalid.inferred.types
   21.14 -// key: compiler.misc.inferred.do.not.conform.to.bounds
   21.15 +// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
   21.16  
   21.17  import java.util.*;
   21.18  
   21.19  class InvalidInferredTypes {
   21.20  
   21.21 -    <T extends List<? super T>> T makeList() {
   21.22 -        return null;
   21.23 -    }
   21.24 +    <S extends String> List<S> m() { return null; }
   21.25  
   21.26 -    public void test() {
   21.27 -        List<? super String> l = makeList();
   21.28 +    void test() {
   21.29 +        List<Integer> li = m();
   21.30      }
   21.31  }
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/tools/javac/diags/examples/NotAllowedClass.java	Mon Apr 23 16:59:32 2012 -0700
    22.3 @@ -0,0 +1,31 @@
    22.4 +/*
    22.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + *
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + *
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + *
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + *
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + */
   22.26 +
   22.27 +// key: compiler.err.class.not.allowed
   22.28 +
   22.29 +class NotAllowedClass {
   22.30 +    void t1() {
   22.31 +        if (true)
   22.32 +            class X {}
   22.33 +    }
   22.34 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/tools/javac/diags/examples/NotAllowedVariable.java	Mon Apr 23 16:59:32 2012 -0700
    23.3 @@ -0,0 +1,31 @@
    23.4 +/*
    23.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 + *
    23.8 + * This code is free software; you can redistribute it and/or modify it
    23.9 + * under the terms of the GNU General Public License version 2 only, as
   23.10 + * published by the Free Software Foundation.
   23.11 + *
   23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 + * version 2 for more details (a copy is included in the LICENSE file that
   23.16 + * accompanied this code).
   23.17 + *
   23.18 + * You should have received a copy of the GNU General Public License version
   23.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 + *
   23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   23.23 + * or visit www.oracle.com if you need additional information or have any
   23.24 + * questions.
   23.25 + */
   23.26 +
   23.27 +// key: compiler.err.variable.not.allowed
   23.28 +
   23.29 +class NotAllowedVariable {
   23.30 +    void t1() {
   23.31 +        if (true)
   23.32 +            int x = 0;
   23.33 +    }
   23.34 +}
    24.1 --- a/test/tools/javac/diags/examples/WhereCaptured.java	Thu Apr 19 12:19:06 2012 -0700
    24.2 +++ b/test/tools/javac/diags/examples/WhereCaptured.java	Mon Apr 23 16:59:32 2012 -0700
    24.3 @@ -26,7 +26,7 @@
    24.4  // key: compiler.misc.where.description.typevar
    24.5  // key: compiler.misc.where.typevar
    24.6  // key: compiler.err.cant.apply.symbol.1
    24.7 -// key: compiler.misc.infer.no.conforming.assignment.exists
    24.8 +// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
    24.9  // key: compiler.misc.captured.type
   24.10  // options: -XDdiags=where,simpleNames
   24.11  // run: simple
    25.1 --- a/test/tools/javac/diags/examples/WhereCaptured1.java	Thu Apr 19 12:19:06 2012 -0700
    25.2 +++ b/test/tools/javac/diags/examples/WhereCaptured1.java	Mon Apr 23 16:59:32 2012 -0700
    25.3 @@ -26,7 +26,7 @@
    25.4  // key: compiler.misc.where.description.typevar
    25.5  // key: compiler.misc.where.typevar
    25.6  // key: compiler.err.cant.apply.symbol.1
    25.7 -// key: compiler.misc.infer.no.conforming.assignment.exists
    25.8 +// key: compiler.misc.inferred.do.not.conform.to.eq.bounds
    25.9  // key: compiler.misc.captured.type
   25.10  // key: compiler.misc.type.null
   25.11  // options: -XDdiags=where,simpleNames
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/tools/javac/diags/examples/WhereFreshTvar.java	Mon Apr 23 16:59:32 2012 -0700
    26.3 @@ -0,0 +1,39 @@
    26.4 +/*
    26.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
    26.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    26.7 + *
    26.8 + * This code is free software; you can redistribute it and/or modify it
    26.9 + * under the terms of the GNU General Public License version 2 only, as
   26.10 + * published by the Free Software Foundation.
   26.11 + *
   26.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   26.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   26.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   26.15 + * version 2 for more details (a copy is included in the LICENSE file that
   26.16 + * accompanied this code).
   26.17 + *
   26.18 + * You should have received a copy of the GNU General Public License version
   26.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   26.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   26.21 + *
   26.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   26.23 + * or visit www.oracle.com if you need additional information or have any
   26.24 + * questions.
   26.25 + */
   26.26 +
   26.27 +// key: compiler.misc.where.fresh.typevar
   26.28 +// key: compiler.misc.where.description.typevar.1
   26.29 +// key: compiler.misc.where.typevar
   26.30 +// key: compiler.misc.invalid.inferred.types
   26.31 +// key: compiler.err.prob.found.req.1
   26.32 +// key: compiler.misc.inferred.do.not.conform.to.upper.bounds
   26.33 +// options: -XDdiags=where,simpleNames
   26.34 +// run: simple
   26.35 +
   26.36 +import java.util.*;
   26.37 +
   26.38 +class WhereFreshTvar {
   26.39 +    <T extends List<T>> T m() {}
   26.40 +
   26.41 +    { List<String> ls = m(); }
   26.42 +}
    27.1 --- a/test/tools/javac/generics/diamond/neg/Neg06.out	Thu Apr 19 12:19:06 2012 -0700
    27.2 +++ b/test/tools/javac/generics/diamond/neg/Neg06.out	Mon Apr 23 16:59:32 2012 -0700
    27.3 @@ -1,2 +1,2 @@
    27.4 -Neg06.java:16:37: compiler.err.prob.found.req.1: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.infer.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>))
    27.5 +Neg06.java:16:37: compiler.err.prob.found.req.1: (compiler.misc.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number))
    27.6  1 error
    28.1 --- a/test/tools/javac/generics/diamond/neg/Neg07.out	Thu Apr 19 12:19:06 2012 -0700
    28.2 +++ b/test/tools/javac/generics/diamond/neg/Neg07.out	Mon Apr 23 16:59:32 2012 -0700
    28.3 @@ -1,2 +1,2 @@
    28.4 -Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
    28.5 +Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.String, java.lang.Number)
    28.6  1 error
    29.1 --- a/test/tools/javac/generics/inference/6315770/T6315770.out	Thu Apr 19 12:19:06 2012 -0700
    29.2 +++ b/test/tools/javac/generics/inference/6315770/T6315770.out	Mon Apr 23 16:59:32 2012 -0700
    29.3 @@ -1,3 +1,3 @@
    29.4  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))
    29.5 -T6315770.java:17:40: compiler.err.prob.found.req.1: (compiler.misc.infer.no.conforming.instance.exists: T, T6315770<T>, T6315770<? super java.lang.String>)
    29.6 +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))
    29.7  2 errors
    30.1 --- a/test/tools/javac/generics/inference/6611449/T6611449.out	Thu Apr 19 12:19:06 2012 -0700
    30.2 +++ b/test/tools/javac/generics/inference/6611449/T6611449.out	Mon Apr 23 16:59:32 2012 -0700
    30.3 @@ -1,5 +1,5 @@
    30.4 -T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S))}
    30.5 -T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch))}
    30.6 -T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)
    30.7 -T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.Integer, S)
    30.8 +T6611449.java:18:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.infer.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S))}
    30.9 +T6611449.java:19:9: compiler.err.cant.apply.symbols: kindname.constructor, T6611449, int,int,{(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T,T), (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)),(compiler.misc.inapplicable.method: kindname.constructor, T6611449, <T>T6611449(T), (compiler.misc.infer.arg.length.mismatch))}
   30.10 +T6611449.java:20:9: compiler.err.cant.apply.symbol.1: kindname.method, m1, T, int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
   30.11 +T6611449.java:21:9: compiler.err.cant.apply.symbol.1: kindname.method, m2, T,T, int,int, kindname.class, T6611449<S>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, S)
   30.12  4 errors
    31.1 --- a/test/tools/javac/generics/inference/6638712/T6638712b.out	Thu Apr 19 12:19:06 2012 -0700
    31.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712b.out	Mon Apr 23 16:59:32 2012 -0700
    31.3 @@ -1,2 +1,2 @@
    31.4 -T6638712b.java:14:21: compiler.err.prob.found.req.1: (compiler.misc.infer.no.conforming.instance.exists: T, T, java.lang.String)
    31.5 +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))
    31.6  1 error
    32.1 --- a/test/tools/javac/generics/inference/6638712/T6638712d.out	Thu Apr 19 12:19:06 2012 -0700
    32.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712d.out	Mon Apr 23 16:59:32 2012 -0700
    32.3 @@ -1,2 +1,2 @@
    32.4 -T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.no.conforming.assignment.exists: int, java.lang.String)
    32.5 +T6638712d.java:16:9: compiler.err.cant.apply.symbol.1: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.String, java.lang.Integer)
    32.6  1 error
    33.1 --- a/test/tools/javac/generics/inference/6638712/T6638712e.out	Thu Apr 19 12:19:06 2012 -0700
    33.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712e.out	Mon Apr 23 16:59:32 2012 -0700
    33.3 @@ -1,2 +1,2 @@
    33.4 -T6638712e.java:17:27: compiler.err.prob.found.req.1: (compiler.misc.infer.no.conforming.instance.exists: X, T6638712e.Foo<X,java.lang.String>, T6638712e.Foo<java.lang.Object,java.lang.String>)
    33.5 +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>))
    33.6  1 error
    34.1 --- a/test/tools/javac/generics/inference/6650759/T6650759m.out	Thu Apr 19 12:19:06 2012 -0700
    34.2 +++ b/test/tools/javac/generics/inference/6650759/T6650759m.out	Mon Apr 23 16:59:32 2012 -0700
    34.3 @@ -1,2 +1,2 @@
    34.4 -T6650759m.java:43:36: compiler.err.prob.found.req: java.util.List<? super java.lang.Integer>, java.util.List<? super java.lang.String>
    34.5 +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))
    34.6  1 error
    35.1 --- a/test/tools/javac/generics/inference/7086601/T7086601a.out	Thu Apr 19 12:19:06 2012 -0700
    35.2 +++ b/test/tools/javac/generics/inference/7086601/T7086601a.out	Mon Apr 23 16:59:32 2012 -0700
    35.3 @@ -1,5 +1,5 @@
    35.4 -T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m1(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String))}
    35.5 -T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m2(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String))}
    35.6 -T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String))}
    35.7 -T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String))}
    35.8 +T7086601a.java:20:9: compiler.err.cant.apply.symbols: kindname.method, m1, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m1(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m1(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object))}
    35.9 +T7086601a.java:24:9: compiler.err.cant.apply.symbols: kindname.method, m2, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m2(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m2(java.lang.Iterable<? super S>,java.lang.Iterable<? super S>,java.lang.Iterable<? super S>), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object))}
   35.10 +T7086601a.java:28:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Integer,java.lang.String,java.lang.Object))}
   35.11 +T7086601a.java:32:9: compiler.err.cant.apply.symbols: kindname.method, m3, java.lang.Iterable<java.lang.String>,java.lang.Iterable<java.lang.Integer>,java.lang.Iterable<java.lang.Double>,{(compiler.misc.inapplicable.method: kindname.method, T7086601, m3(java.lang.Object), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, T7086601, <S>m3(java.lang.Iterable<? super S>...), (compiler.misc.incompatible.upper.bounds: S, java.lang.Double,java.lang.Integer,java.lang.String,java.lang.Object))}
   35.12  4 errors
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/test/tools/javac/generics/inference/7154127/T7154127.java	Mon Apr 23 16:59:32 2012 -0700
    36.3 @@ -0,0 +1,21 @@
    36.4 +/**
    36.5 + * @test /nodynamiccopyright/
    36.6 + * @bug 7154127
    36.7 + * @summary Inference cleanup: remove bound check analysis from visitors in Types.java
    36.8 + * @compile/fail/ref=T7154127.out -XDrawDiagnostics T7154127.java
    36.9 + */
   36.10 +class T7154127 {
   36.11 +
   36.12 +    static class B<V> {}
   36.13 +
   36.14 +    static class D extends B<E> {}
   36.15 +    static class E extends B<D> {}
   36.16 +
   36.17 +    static class Triple<U,V,W> { }
   36.18 +
   36.19 +    static <T, Y extends B<U>, U extends B<Y>> Triple<T, Y, U> m() { return null; }
   36.20 +
   36.21 +    void test() {
   36.22 +       Triple<B, ? extends D, ? extends E> t = m();
   36.23 +    }
   36.24 +}
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/test/tools/javac/generics/inference/7154127/T7154127.out	Mon Apr 23 16:59:32 2012 -0700
    37.3 @@ -0,0 +1,2 @@
    37.4 +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>))
    37.5 +1 error
    38.1 --- a/test/tools/javac/parser/JavacParserTest.java	Thu Apr 19 12:19:06 2012 -0700
    38.2 +++ b/test/tools/javac/parser/JavacParserTest.java	Mon Apr 23 16:59:32 2012 -0700
    38.3 @@ -1,5 +1,5 @@
    38.4  /*
    38.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    38.6 + * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
    38.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    38.8   *
    38.9   * This code is free software; you can redistribute it and/or modify it
   38.10 @@ -596,8 +596,8 @@
   38.11      public void testVariableInIfThen3() throws IOException {
   38.12  
   38.13          String code = "package t; class Test { "+
   38.14 -                "private static void t(String name) { " +
   38.15 -                "if (name != null) abstract } }";
   38.16 +                "private static void t() { " +
   38.17 +                "if (true) abstract class F {} }}";
   38.18          DiagnosticCollector<JavaFileObject> coll =
   38.19                  new DiagnosticCollector<JavaFileObject>();
   38.20          JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
   38.21 @@ -612,7 +612,51 @@
   38.22          }
   38.23  
   38.24          assertEquals("testVariableInIfThen3",
   38.25 -                Arrays.<String>asList("compiler.err.illegal.start.of.expr"),
   38.26 +                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
   38.27 +    }
   38.28 +
   38.29 +    public void testVariableInIfThen4() throws IOException {
   38.30 +
   38.31 +        String code = "package t; class Test { "+
   38.32 +                "private static void t(String name) { " +
   38.33 +                "if (name != null) interface X {} } }";
   38.34 +        DiagnosticCollector<JavaFileObject> coll =
   38.35 +                new DiagnosticCollector<JavaFileObject>();
   38.36 +        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
   38.37 +                null, Arrays.asList(new MyFileObject(code)));
   38.38 +
   38.39 +        ct.parse();
   38.40 +
   38.41 +        List<String> codes = new LinkedList<String>();
   38.42 +
   38.43 +        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
   38.44 +            codes.add(d.getCode());
   38.45 +        }
   38.46 +
   38.47 +        assertEquals("testVariableInIfThen4",
   38.48 +                Arrays.<String>asList("compiler.err.class.not.allowed"), codes);
   38.49 +    }
   38.50 +
   38.51 +    public void testVariableInIfThen5() throws IOException {
   38.52 +
   38.53 +        String code = "package t; class Test { "+
   38.54 +                "private static void t() { " +
   38.55 +                "if (true) } }";
   38.56 +        DiagnosticCollector<JavaFileObject> coll =
   38.57 +                new DiagnosticCollector<JavaFileObject>();
   38.58 +        JavacTaskImpl ct = (JavacTaskImpl) tool.getTask(null, null, coll, null,
   38.59 +                null, Arrays.asList(new MyFileObject(code)));
   38.60 +
   38.61 +        ct.parse();
   38.62 +
   38.63 +        List<String> codes = new LinkedList<String>();
   38.64 +
   38.65 +        for (Diagnostic<? extends JavaFileObject> d : coll.getDiagnostics()) {
   38.66 +            codes.add(d.getCode());
   38.67 +        }
   38.68 +
   38.69 +        assertEquals("testVariableInIfThen5",
   38.70 +                Arrays.<String>asList("compiler.err.illegal.start.of.stmt"),
   38.71                  codes);
   38.72      }
   38.73  
   38.74 @@ -808,8 +852,6 @@
   38.75          testPositionBrokenSource126732b();
   38.76  
   38.77          // Fails, these tests yet to be addressed
   38.78 -        testVariableInIfThen1();
   38.79 -        testVariableInIfThen2();
   38.80          testPositionForEnumModifiers();
   38.81          testStartPositionEnumConstantInit();
   38.82      }
   38.83 @@ -821,7 +863,11 @@
   38.84          testPreferredPositionForBinaryOp();
   38.85          testStartPositionForMethodWithoutModifiers();
   38.86          testVarPos();
   38.87 +        testVariableInIfThen1();
   38.88 +        testVariableInIfThen2();
   38.89          testVariableInIfThen3();
   38.90 +        testVariableInIfThen4();
   38.91 +        testVariableInIfThen5();
   38.92          testMissingExponent();
   38.93          testTryResourcePos();
   38.94          testOperatorMissingError();

mercurial