# HG changeset patch # User tbell # Date 1226087149 28800 # Node ID 5db12b3a75ea0f1e4f4a7f1a2232d1e5988e4d5b # Parent 3cbbc9424f435ca3ccb64e26e5ea216420a44b7b# Parent 1b144d394c434cedcb07d94f739bb238dcf0d4e6 Merge diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/api/Formattable.java --- a/langtools/src/share/classes/com/sun/tools/javac/api/Formattable.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/api/Formattable.java Fri Nov 07 11:45:49 2008 -0800 @@ -49,4 +49,23 @@ * @return a string representing the object's kind */ String getKind(); + + static class LocalizedString implements Formattable { + String key; + + public LocalizedString(String key) { + this.key = key; + } + + public String toString(java.util.Locale l, Messages messages) { + return messages.getLocalizedString(l, key); + } + public String getKind() { + return "LocalizedString"; + } + + public String toString() { + return key; + } + } } diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java Fri Nov 07 11:45:49 2008 -0800 @@ -361,6 +361,8 @@ for (Symbol sup = clazz; sup != null && sup != this.owner; sup = types.supertype(sup.type).tsym) { + while (sup.type.tag == TYPEVAR) + sup = sup.type.getUpperBound().tsym; if (sup.type.isErroneous()) return true; // error recovery if ((sup.flags() & COMPOUND) != 0) @@ -1183,7 +1185,9 @@ * as possible implementations. */ public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) { - for (Type t = origin.type; t.tag == CLASS; t = types.supertype(t)) { + for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) { + while (t.tag == TYPEVAR) + t = t.getUpperBound(); TypeSymbol c = t.tsym; for (Scope.Entry e = c.members().lookup(name); e.scope != null; diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/code/Type.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java Fri Nov 07 11:45:49 2008 -0800 @@ -360,17 +360,6 @@ public boolean isUnbound() { return false; } public Type withTypeVar(Type t) { return this; } - public static List removeBounds(List ts) { - ListBuffer result = new ListBuffer(); - for(;ts.nonEmpty(); ts = ts.tail) { - result.append(ts.head.removeBounds()); - } - return result.toList(); - } - public Type removeBounds() { - return this; - } - /** The underlying method type of this type. */ public MethodType asMethodType() { throw new AssertionError(); } @@ -489,10 +478,6 @@ return new WildcardType(t, kind, tsym, bound); } - public Type removeBounds() { - return isUnbound() ? this : type; - } - public Type getExtendsBound() { if (kind == EXTENDS) return type; diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/code/Types.java --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Nov 07 11:45:49 2008 -0800 @@ -709,16 +709,13 @@ case UNDETVAR: if (s.tag == WILDCARD) { UndetVar undetvar = (UndetVar)t; - - // Because of wildcard capture, s must be on the left - // hand side of an assignment. Furthermore, t is an - // underconstrained type variable, for example, one - // that is only used in the return type of a method. - // If the type variable is truly underconstrained, it - // cannot have any low bounds: - assert undetvar.lobounds.isEmpty() : undetvar; - undetvar.inst = glb(upperBound(s), undetvar.inst); + // We should check instantiated type against any of the + // undetvar's lower bounds. + for (Type t2 : undetvar.lobounds) { + if (!isSubtype(t2, undetvar.inst)) + return false; + } return true; } else { return isSameType(t, s); @@ -3367,33 +3364,67 @@ * quantifiers) only */ private Type rewriteQuantifiers(Type t, boolean high, boolean rewriteTypeVars) { - ListBuffer from = new ListBuffer(); - ListBuffer to = new ListBuffer(); - adaptSelf(t, from, to); - ListBuffer rewritten = new ListBuffer(); - List formals = from.toList(); - boolean changed = false; - for (Type arg : to.toList()) { - Type bound; - if (rewriteTypeVars && arg.tag == TYPEVAR) { - TypeVar tv = (TypeVar)arg; - bound = high ? tv.bound : syms.botType; - } else { - bound = high ? upperBound(arg) : lowerBound(arg); + return new Rewriter(high, rewriteTypeVars).rewrite(t); + } + + class Rewriter extends UnaryVisitor { + + boolean high; + boolean rewriteTypeVars; + + Rewriter(boolean high, boolean rewriteTypeVars) { + this.high = high; + this.rewriteTypeVars = rewriteTypeVars; + } + + Type rewrite(Type t) { + ListBuffer from = new ListBuffer(); + ListBuffer to = new ListBuffer(); + adaptSelf(t, from, to); + ListBuffer rewritten = new ListBuffer(); + List formals = from.toList(); + boolean changed = false; + for (Type arg : to.toList()) { + Type bound = visit(arg); + if (arg != bound) { + changed = true; + bound = high ? makeExtendsWildcard(bound, (TypeVar)formals.head) + : makeSuperWildcard(bound, (TypeVar)formals.head); + } + rewritten.append(bound); + formals = formals.tail; } - Type newarg = bound; - if (arg != bound) { - changed = true; - newarg = high ? makeExtendsWildcard(bound, (TypeVar)formals.head) - : makeSuperWildcard(bound, (TypeVar)formals.head); - } - rewritten.append(newarg); - formals = formals.tail; + if (changed) + return subst(t.tsym.type, from.toList(), rewritten.toList()); + else + return t; + } + + public Type visitType(Type t, Void s) { + return high ? upperBound(t) : lowerBound(t); + } + + @Override + public Type visitCapturedType(CapturedType t, Void s) { + return visitWildcardType(t.wildcard, null); } - if (changed) - return subst(t.tsym.type, from.toList(), rewritten.toList()); - else - return t; + + @Override + public Type visitTypeVar(TypeVar t, Void s) { + if (rewriteTypeVars) + return high ? t.bound : syms.botType; + else + return t; + } + + @Override + public Type visitWildcardType(WildcardType t, Void s) { + Type bound = high ? t.getExtendsBound() : + t.getSuperBound(); + if (bound == null) + bound = high ? syms.objectType : syms.botType; + return bound; + } } /** diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 07 11:45:49 2008 -0800 @@ -706,13 +706,13 @@ } } - // Check that the variable's declared type is well-formed. - chk.validate(tree.vartype, env); - VarSymbol v = tree.sym; Lint lint = env.info.lint.augment(v.attributes_field, v.flags()); Lint prevLint = chk.setLint(lint); + // Check that the variable's declared type is well-formed. + chk.validate(tree.vartype, env); + try { chk.checkDeprecatedAnnotation(tree.pos(), v); @@ -2007,6 +2007,10 @@ log.error(pos, "type.var.cant.be.deref"); return syms.errSymbol; } else { + Symbol sym2 = (sym.flags() & Flags.PRIVATE) != 0 ? + rs.new AccessError(env, site, sym) : + sym; + rs.access(sym2, pos, site, name, true); return sym; } case ERROR: @@ -2374,16 +2378,14 @@ } if (warned && sym.type.tag == FORALL) { - String typeargs = ""; - if (typeargtypes != null && typeargtypes.nonEmpty()) { - typeargs = "<" + Type.toString(typeargtypes) + ">"; - } chk.warnUnchecked(env.tree.pos(), "unchecked.meth.invocation.applied", - sym, - sym.location(), - typeargs, - Type.toString(argtypes)); + kindName(sym), + sym.name, + rs.methodArguments(sym.type.getParameterTypes()), + rs.methodArguments(argtypes), + kindName(sym.location()), + sym.location()); owntype = new MethodType(owntype.getParameterTypes(), types.erasure(owntype.getReturnType()), owntype.getThrownTypes(), @@ -2516,7 +2518,10 @@ // accept class or interface or typevar as first bound. Type b = checkBase(bs.head, tree.bounds.head, env, false, false, false); boundSet.add(types.erasure(b)); - if (b.tag == TYPEVAR) { + if (b.isErroneous()) { + a.bound = b; + } + else if (b.tag == TYPEVAR) { // if first bound was a typevar, do not accept further bounds. if (tree.bounds.tail.nonEmpty()) { log.error(tree.bounds.tail.head.pos(), @@ -2530,7 +2535,9 @@ for (JCExpression bound : tree.bounds.tail) { bs = bs.tail; Type i = checkBase(bs.head, bound, env, false, true, false); - if (i.tag == CLASS) + if (i.isErroneous()) + a.bound = i; + else if (i.tag == CLASS) chk.checkNotRepeated(bound.pos(), types.erasure(i), boundSet); } } diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/comp/Check.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Nov 07 11:45:49 2008 -0800 @@ -424,43 +424,43 @@ * @param bs The bound. */ private void checkExtends(DiagnosticPosition pos, Type a, TypeVar bs) { - if (a.tag == TYPEVAR && ((TypeVar)a).isCaptured()) { - CapturedType ct = (CapturedType)a; - boolean ok; - if (ct.bound.isErroneous()) {//capture doesn't exist - ok = false; + if (a.isUnbound()) { + return; + } else if (a.tag != WILDCARD) { + a = types.upperBound(a); + for (List l = types.getBounds(bs); l.nonEmpty(); l = l.tail) { + if (!types.isSubtype(a, l.head)) { + log.error(pos, "not.within.bounds", a); + return; + } + } + } else if (a.isExtendsBound()) { + if (!types.isCastable(bs.getUpperBound(), types.upperBound(a), Warner.noWarnings)) + log.error(pos, "not.within.bounds", a); + } else if (a.isSuperBound()) { + if (types.notSoftSubtype(types.lowerBound(a), bs.getUpperBound())) + log.error(pos, "not.within.bounds", a); + } + } + + /** Check that a type is within some bounds. + * + * Used in TypeApply to verify that, e.g., X in V is a valid + * type argument. + * @param pos Position to be used for error reporting. + * @param a The type that should be bounded by bs. + * @param bs The bound. + */ + private void checkCapture(JCTypeApply tree) { + List args = tree.getTypeArguments(); + for (Type arg : types.capture(tree.type).getTypeArguments()) { + if (arg.tag == TYPEVAR && arg.getUpperBound().isErroneous()) { + log.error(args.head.pos, "not.within.bounds", args.head.type); + break; } - else { - switch (ct.wildcard.kind) { - case EXTENDS: - ok = types.isCastable(bs.getUpperBound(), - types.upperBound(a), - Warner.noWarnings); - break; - case SUPER: - ok = !types.notSoftSubtype(types.lowerBound(a), - bs.getUpperBound()); - break; - case UNBOUND: - ok = true; - break; - default: - throw new AssertionError("Invalid bound kind"); - } - } - if (!ok) - log.error(pos, "not.within.bounds", a); + args = args.tail; } - else { - a = types.upperBound(a); - for (List l = types.getBounds(bs); l.nonEmpty(); l = l.tail) { - if (!types.isSubtype(a, l.head)) { - log.error(pos, "not.within.bounds", a); - return; - } - } - } - } + } /** Check that type is different from 'void'. * @param pos Position to be used for error reporting. @@ -802,10 +802,10 @@ public void visitTypeApply(JCTypeApply tree) { if (tree.type.tag == CLASS) { - List formals = tree.type.tsym.type.getTypeArguments(); - List actuals = types.capture(tree.type).getTypeArguments(); + List formals = tree.type.tsym.type.allparams(); + List actuals = tree.type.allparams(); List args = tree.arguments; - List forms = formals; + List forms = tree.type.tsym.type.getTypeArguments(); ListBuffer tvars_buf = new ListBuffer(); // For matching pairs of actual argument types `a' and @@ -826,24 +826,28 @@ } args = tree.arguments; + List tvars_cap = types.substBounds(formals, + formals, + types.capture(tree.type).allparams()); + while (args.nonEmpty() && tvars_cap.nonEmpty()) { + // Let the actual arguments know their bound + args.head.type.withTypeVar((TypeVar)tvars_cap.head); + args = args.tail; + tvars_cap = tvars_cap.tail; + } + + args = tree.arguments; List tvars = tvars_buf.toList(); + while (args.nonEmpty() && tvars.nonEmpty()) { - // Let the actual arguments know their bound - args.head.type.withTypeVar(tvars.head); + checkExtends(args.head.pos(), + args.head.type, + tvars.head); args = args.tail; tvars = tvars.tail; } - args = tree.arguments; - tvars = tvars_buf.toList(); - while (args.nonEmpty() && tvars.nonEmpty()) { - checkExtends(args.head.pos(), - actuals.head, - tvars.head); - args = args.tail; - tvars = tvars.tail; - actuals = actuals.tail; - } + checkCapture(tree); // Check that this type is either fully parameterized, or // not parameterized at all. diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Nov 07 11:45:49 2008 -0800 @@ -30,6 +30,8 @@ import com.sun.tools.javac.code.*; import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.tree.*; +import com.sun.tools.javac.api.Formattable.LocalizedString; +import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*; import com.sun.tools.javac.code.Type.*; import com.sun.tools.javac.code.Symbol.*; @@ -40,6 +42,9 @@ import static com.sun.tools.javac.code.TypeTags.*; import javax.lang.model.element.ElementVisitor; +import java.util.Map; +import java.util.HashMap; + /** Helper class for name resolution, used mostly by the attribution phase. * *

This is NOT part of any API supported by Sun Microsystems. If @@ -554,7 +559,6 @@ boolean useVarargs, boolean operator) { if (sym.kind == ERR) return bestSoFar; - if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar; assert sym.kind < AMBIGUOUS; try { if (rawInstantiate(env, site, sym, argtypes, typeargtypes, @@ -651,8 +655,9 @@ // both abstract or both concrete if (!m1Abstract && !m2Abstract) return new AmbiguityError(m1, m2); - // check for same erasure - if (!types.isSameType(m1.erasure(types), m2.erasure(types))) + // check that both signatures have the same erasure + if (!types.isSameTypes(m1.erasure(types).getParameterTypes(), + m2.erasure(types).getParameterTypes())) return new AmbiguityError(m1, m2); // both abstract, neither overridden; merge throws clause and result type Symbol result; @@ -1192,15 +1197,23 @@ Name name, List argtypes, List typeargtypes) { - Symbol sym = findFun(env, name, argtypes, typeargtypes, false, env.info.varArgs=false); - if (varargsEnabled && sym.kind >= WRONG_MTHS) { - sym = findFun(env, name, argtypes, typeargtypes, true, false); - if (sym.kind >= WRONG_MTHS) - sym = findFun(env, name, argtypes, typeargtypes, true, env.info.varArgs=true); + Symbol sym = methodNotFound; + List steps = methodResolutionSteps; + while (steps.nonEmpty() && + steps.head.isApplicable(boxingEnabled, varargsEnabled) && + sym.kind >= ERRONEOUS) { + sym = findFun(env, name, argtypes, typeargtypes, + steps.head.isBoxingRequired, + env.info.varArgs = steps.head.isVarargsRequired); + methodResolutionCache.put(steps.head, sym); + steps = steps.tail; } - if (sym.kind >= AMBIGUOUS) { - sym = access( - sym, pos, env.enclClass.sym.type, name, false, argtypes, typeargtypes); + if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error + MethodResolutionPhase errPhase = + firstErroneousResolutionPhase(); + sym = access(methodResolutionCache.get(errPhase), + pos, env.enclClass.sym.type, name, false, argtypes, typeargtypes); + env.info.varArgs = errPhase.isVarargsRequired; } return sym; } @@ -1217,17 +1230,23 @@ Symbol resolveQualifiedMethod(DiagnosticPosition pos, Env env, Type site, Name name, List argtypes, List typeargtypes) { - Symbol sym = findMethod(env, site, name, argtypes, typeargtypes, false, - env.info.varArgs=false, false); - if (varargsEnabled && sym.kind >= WRONG_MTHS) { - sym = findMethod(env, site, name, argtypes, typeargtypes, true, - false, false); - if (sym.kind >= WRONG_MTHS) - sym = findMethod(env, site, name, argtypes, typeargtypes, true, - env.info.varArgs=true, false); + Symbol sym = methodNotFound; + List steps = methodResolutionSteps; + while (steps.nonEmpty() && + steps.head.isApplicable(boxingEnabled, varargsEnabled) && + sym.kind >= ERRONEOUS) { + sym = findMethod(env, site, name, argtypes, typeargtypes, + steps.head.isBoxingRequired(), + env.info.varArgs = steps.head.isVarargsRequired(), false); + methodResolutionCache.put(steps.head, sym); + steps = steps.tail; } - if (sym.kind >= AMBIGUOUS) { - sym = access(sym, pos, site, name, true, argtypes, typeargtypes); + if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error + MethodResolutionPhase errPhase = + firstErroneousResolutionPhase(); + sym = access(methodResolutionCache.get(errPhase), + pos, site, name, true, argtypes, typeargtypes); + env.info.varArgs = errPhase.isVarargsRequired; } return sym; } @@ -1268,14 +1287,22 @@ Type site, List argtypes, List typeargtypes) { - Symbol sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, false, env.info.varArgs=false); - if (varargsEnabled && sym.kind >= WRONG_MTHS) { - sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, true, false); - if (sym.kind >= WRONG_MTHS) - sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, true, env.info.varArgs=true); + Symbol sym = methodNotFound; + List steps = methodResolutionSteps; + while (steps.nonEmpty() && + steps.head.isApplicable(boxingEnabled, varargsEnabled) && + sym.kind >= ERRONEOUS) { + sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, + steps.head.isBoxingRequired(), + env.info.varArgs = steps.head.isVarargsRequired()); + methodResolutionCache.put(steps.head, sym); + steps = steps.tail; } - if (sym.kind >= AMBIGUOUS) { - sym = access(sym, pos, site, names.init, true, argtypes, typeargtypes); + if (sym.kind >= AMBIGUOUS) {//if nothing is found return the 'first' error + MethodResolutionPhase errPhase = firstErroneousResolutionPhase(); + sym = access(methodResolutionCache.get(errPhase), + pos, site, names.init, true, argtypes, typeargtypes); + env.info.varArgs = errPhase.isVarargsRequired(); } return sym; } @@ -1452,6 +1479,12 @@ error.report(log, tree.pos(), type.getEnclosingType(), null, null, null); } + private final LocalizedString noArgs = new LocalizedString("compiler.misc.no.args"); + + public Object methodArguments(List argtypes) { + return argtypes.isEmpty() ? noArgs : argtypes; + } + /** Root class for resolve errors. * Instances of this class indicate "Symbol not found". * Instances of subclass indicate other errors. @@ -1558,8 +1591,8 @@ "cant.apply.symbol" + (explanation != null ? ".1" : ""), kindname, ws.name == names.init ? ws.owner.name : ws.name, - ws.type.getParameterTypes(), - argtypes, + methodArguments(ws.type.getParameterTypes()), + methodArguments(argtypes), kindName(ws.owner), ws.owner.type, explanation); @@ -1733,4 +1766,50 @@ pair.sym2.location(site, types)); } } + + enum MethodResolutionPhase { + BASIC(false, false), + BOX(true, false), + VARARITY(true, true); + + boolean isBoxingRequired; + boolean isVarargsRequired; + + MethodResolutionPhase(boolean isBoxingRequired, boolean isVarargsRequired) { + this.isBoxingRequired = isBoxingRequired; + this.isVarargsRequired = isVarargsRequired; + } + + public boolean isBoxingRequired() { + return isBoxingRequired; + } + + public boolean isVarargsRequired() { + return isVarargsRequired; + } + + public boolean isApplicable(boolean boxingEnabled, boolean varargsEnabled) { + return (varargsEnabled || !isVarargsRequired) && + (boxingEnabled || !isBoxingRequired); + } + } + + private Map methodResolutionCache = + new HashMap(MethodResolutionPhase.values().length); + + final List methodResolutionSteps = List.of(BASIC, BOX, VARARITY); + + private MethodResolutionPhase firstErroneousResolutionPhase() { + MethodResolutionPhase bestSoFar = BASIC; + Symbol sym = methodNotFound; + List steps = methodResolutionSteps; + while (steps.nonEmpty() && + steps.head.isApplicable(boxingEnabled, varargsEnabled) && + sym.kind >= WRONG_MTHS) { + sym = methodResolutionCache.get(steps.head); + bestSoFar = steps.head; + steps = steps.tail; + } + return bestSoFar; + } } diff -r 1b144d394c43 -r 5db12b3a75ea langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Nov 07 11:45:49 2008 -0800 @@ -745,7 +745,10 @@ compiler.warn.unchecked.cast.to.type=\ [unchecked] unchecked cast to type {0} compiler.warn.unchecked.meth.invocation.applied=\ - [unchecked] unchecked method invocation: {0} in {1} is applied to {2}({3}) + [unchecked] unchecked method invocation: {0} {1} in {4} {5} is applied to given types\n\ + required: {2}\n\ + found: {3} + compiler.warn.unchecked.generic.array.creation=\ [unchecked] unchecked generic array creation of type {0} for varargs parameter @@ -771,7 +774,7 @@ Cannot find annotation method ''{1}()'' in type ''{0}'': {2} compiler.warn.raw.class.use=\ - [raw-type] found raw type: {0}\n\ + [rawtypes] found raw type: {0}\n\ missing type parameters for generic class {1} ##### @@ -1062,6 +1065,9 @@ package ##### +compiler.misc.no.args=\ + no arguments + compiler.err.override.static=\ {0}; overriding method is static compiler.err.override.meth=\ diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/6304921/T6304921.out --- a/langtools/test/tools/javac/6304921/T6304921.out Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/test/tools/javac/6304921/T6304921.out Fri Nov 07 11:45:49 2008 -0800 @@ -1,4 +1,4 @@ -T6304921.java:671/671/680: warning: [raw-type] found raw type: java.util.ArrayList +T6304921.java:671/671/680: warning: [rawtypes] found raw type: java.util.ArrayList missing type parameters for generic class java.util.ArrayList List list = new ArrayList(); ^ diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/6758789/T6758789a.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6758789/T6758789a.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6758789 + * @summary 6758789: Some method resolution diagnostic should be improved + * @author Maurizio Cimadamore + * + * @compile/fail/ref=T6758789a.out -XDrawDiagnostics T6758789a.java + */ + +class T6758789a { + void m1() {} + void m2(int i) {} + void test() { + m1(1); + m2(); + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/6758789/T6758789a.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6758789/T6758789a.out Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,3 @@ +T6758789a.java:37:9: compiler.err.cant.apply.symbol: kindname.method, m1, compiler.misc.no.args, int, kindname.class, T6758789a, null +T6758789a.java:38:9: compiler.err.cant.apply.symbol: kindname.method, m2, int, compiler.misc.no.args, kindname.class, T6758789a, null +2 errors \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/6758789/T6758789b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6758789/T6758789b.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,41 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6758789 + * @summary 6758789: Some method resolution diagnostic should be improved + * @author Maurizio Cimadamore + * + * @compile/fail/ref=T6758789b.out -Werror -XDrawDiagnostics -Xlint:unchecked T6758789b.java + */ + +class T6758789a { + class Foo {} + + void m(Foo foo) {} + + void test() { + m(new Foo()); + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/6758789/T6758789b.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/6758789/T6758789b.out Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,3 @@ +T6758789b.java:39:11: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo +T6758789b.java:39:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo, T6758789a.Foo, kindname.class, T6758789a +2 warnings diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/cast/6548436/T6548436a.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/cast/6548436/T6548436a.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6548436 + * @summary Incorrect inconvertible types error + * @author Maurizio Cimadamore + * + * @compile T6548436a.java + */ + +public class T6548436a { + + static class Base> {} + + static void test(Base je) { + Object o = (Base)je; + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/cast/6548436/T6548436b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/cast/6548436/T6548436b.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6548436 + * @summary Incorrect inconvertible types error + * @author Maurizio Cimadamore + * + * @compile T6548436b.java + */ + +public class T6548436b { + + enum E { } + + static void test(Enum o) { + Object e = (E)o; + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/cast/6548436/T6548436c.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/cast/6548436/T6548436c.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,42 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6548436 + * @summary Incorrect inconvertible types error + * @author Maurizio Cimadamore + * + * @compile T6548436c.java + */ + +public class T6548436c { + + interface A> { } + + interface B extends A { } + + static void test(A a) { + Object o = (B)a; + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/cast/6548436/T6548436d.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/cast/6548436/T6548436d.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6548436 + * @summary Incorrect inconvertible types error + * @author Maurizio Cimadamore + * + * @compile/fail T6548436d.java + */ + +public class T6548436d { + + static class Base> {} + + static void test(Base je) { + Object o = (Base)je; + } +} \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/6487370/T6487370.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/6487370/T6487370.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6487370 + * @author Maurizio Cimadamore + * @summary javac incorrectly gives ambiguity warning with override-equivalent abstract inherited methods + */ + +public class T6487370 { + + interface I1 { + String m(Number n); + } + + interface I2 { + Object m(Number n); + } + + static abstract class X implements I1, I2 { + String test() { + return m(0.0f); + } + } + + static class W extends X { + public String m(Number n) { + return "Hello!"; + } + } + + public static void main(String args[]) { + System.out.println(new W().test()); + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/6531090/T6531090b.java --- a/langtools/test/tools/javac/generics/6531090/T6531090b.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/test/tools/javac/generics/6531090/T6531090b.java Fri Nov 07 11:45:49 2008 -0800 @@ -23,7 +23,7 @@ /* * @test - * @bug 6531090 + * @bug 6531090 6711619 * * @summary Cannot access methods/fields of a captured type belonging to an intersection type * @author Maurizio Cimadamore @@ -32,12 +32,20 @@ public class T6531090b { static class A { - public void a() {} - public A a; + public void a1() {} + protected void a2() {} + void a3() {} + public A a1; + protected A a2; + A a3; } static class B extends A { - public void b(){} - public B b; + public void b1() {} + protected void b2() {} + void b3() {} + public B b1; + protected B b2; + B b3; } static interface I{ void i(); @@ -65,18 +73,35 @@ } static void testMemberMethods(C arg) { - arg.t.a(); - arg.t.b(); + arg.t.a1(); + arg.t.a2(); + arg.t.a3(); + arg.t.b1(); + arg.t.b2(); + arg.t.b3(); arg.t.i1(); - arg.w.a(); - arg.w.b(); + arg.w.a1(); + arg.w.a2(); + arg.w.a3(); + arg.w.b1(); + arg.w.b2(); + arg.w.b3(); arg.w.i1(); } static void testMemberFields(C arg) { - A ta = arg.t.a; - B tb = arg.t.b; - A wa = arg.w.a; - B wb = arg.w.b; + A ta; B tb; + ta = arg.t.a1; + ta = arg.t.a2; + ta = arg.t.a3; + tb = arg.t.b1; + tb = arg.t.b2; + tb = arg.t.b3; + ta = arg.w.a1; + ta = arg.w.a2; + ta = arg.w.a3; + tb = arg.w.b1; + tb = arg.w.b2; + tb = arg.w.b3; } } diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/6711619/T6711619a.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/6711619/T6711619a.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,74 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6711619 + * + * @summary javac doesn't allow access to protected members in intersection types + * @author Maurizio Cimadamore + * + * @compile/fail/ref=T6711619a.out -XDrawDiagnostics T6711619a.java + */ +class T6711619a { + + static class A { + private void a() {} + private A a; + } + static class B extends A { + private B b() {} + private B b; + } + static interface I{ + void i(); + } + static interface I1{ + void i1(); + } + static class E extends B implements I, I1{ + public void i() {} + public void i1() {} + } + static class C{ + T t; + W w; + C(W w, T t) { + this.w = w; + this.t = t; + } + } + + static void testMemberMethods(C arg) { + arg.t.a(); + arg.t.b(); + } + + static void testMemberFields(C arg) { + A ta; B tb; + ta = arg.t.a; + tb = arg.t.b; + ta = arg.w.a; + tb = arg.w.b; + } +} \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/6711619/T6711619a.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/6711619/T6711619a.out Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,7 @@ +T6711619a.java:63:14: compiler.err.report.access: a(), private, T6711619a.A +T6711619a.java:64:14: compiler.err.report.access: b(), private, T6711619a.B +T6711619a.java:69:19: compiler.err.report.access: a, private, T6711619a.A +T6711619a.java:70:19: compiler.err.report.access: b, private, T6711619a.B +T6711619a.java:71:19: compiler.err.report.access: a, private, T6711619a.A +T6711619a.java:72:19: compiler.err.report.access: b, private, T6711619a.B +6 errors diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/6711619/T6711619b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/6711619/T6711619b.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,64 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6711619 + * + * @summary javac doesn't allow access to protected members in intersection types + * @author Maurizio Cimadamore + * + * @compile/fail/ref=T6711619b.out -XDrawDiagnostics T6711619b.java + */ + +class T6711619b { + static class X1> { + private int i; + E e; + int f() { + return e.i; + } + } + + static class X2> { + static private int i; + int f() { + return E.i; + } + } + + static class X3 & java.io.Serializable> { + private int i; + E e; + int f() { + return e.i; + } + } + + static class X4 & java.io.Serializable> { + static private int i; + int f() { + return E.i; + } + } +} \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/6711619/T6711619b.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/6711619/T6711619b.out Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,5 @@ +T6711619b.java:39:22: compiler.err.report.access: i, private, T6711619b.X1 +T6711619b.java:46:22: compiler.err.report.access: i, private, T6711619b.X2 +T6711619b.java:54:22: compiler.err.report.access: i, private, T6711619b.X3 +T6711619b.java:61:22: compiler.err.report.access: i, private, T6711619b.X4 +4 errors diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/T6557954.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/T6557954.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,36 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6557954 + * @summary Inner class type parameters doesn't get substituted when checking type well-formedness + * @author Maurizio Cimadamore + * + * @compile T6557954.java + */ + +class T6557954 { + class Foo {} + T6557954.Foo f; +} \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/inference/6718364/T6718364.out --- a/langtools/test/tools/javac/generics/inference/6718364/T6718364.out Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/test/tools/javac/generics/inference/6718364/T6718364.out Fri Nov 07 11:45:49 2008 -0800 @@ -1,3 +1,3 @@ T6718364.java:36:32: compiler.warn.prob.found.req: (- compiler.misc.unchecked.assign), T6718364.X, T6718364.X -T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied: m(T6718364.X,T), T6718364, , T6718364.X>,T6718364.X +T6718364.java:36:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6718364.X,T, T6718364.X>,T6718364.X, kindname.class, T6718364 2 warnings \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/typevars/6680106/T6680106.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/typevars/6680106/T6680106.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6680106 + * @summary StackOverFlowError for Cyclic inheritance in TypeParameters with ArrayType Bounds + * @author Maurizio Cimadamore + * @compile/fail/ref=T6680106.out -XDrawDiagnostics T6680106.java + */ + +class T6680106 { + class A0 {} + class A1 {} + class A2 {} + class A3 {} + class A5 {} + class A6 {} + class A7 {} +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/typevars/6680106/T6680106.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/typevars/6680106/T6680106.out Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,13 @@ +T6680106.java:34:25: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) +T6680106.java:35:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) +T6680106.java:35:40: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) +T6680106.java:36:25: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) +T6680106.java:36:40: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class) +T6680106.java:36:55: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) +T6680106.java:37:30: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) +T6680106.java:38:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) +T6680106.java:38:50: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) +T6680106.java:39:30: compiler.err.type.found.req: S[], (- compiler.misc.type.req.class) +T6680106.java:39:50: compiler.err.type.found.req: U[], (- compiler.misc.type.req.class) +T6680106.java:39:70: compiler.err.type.found.req: T[], (- compiler.misc.type.req.class) +12 errors \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/wildcards/6651719/T6651719b.java --- a/langtools/test/tools/javac/generics/wildcards/6651719/T6651719b.java Thu Nov 06 12:10:41 2008 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. - */ - -/* - * @test - * @bug 6651719 - * @summary Compiler crashes possibly during forward reference of TypeParameter - * @compile T6651719b.java - */ -import java.util.*; - -public class T6651719b { - void m(T t, List> list) {} - void test(List> list) { - m("", list); - } -} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/wildcards/6762569/T6762569a.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/wildcards/6762569/T6762569a.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6762569 + * @summary Javac crashes with AssertionError in Types.containedBy + * @compile T6762569a.java + */ +import java.util.*; + +class T6762569a { + void m(T t, List> list) {} + + void test(List> list) { + m("", list); + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/wildcards/6762569/T6762569b.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,38 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6762569 + * @summary Javac crashes with AssertionError in Types.containedBy + * @compile/fail T6762569b.java + */ +import java.util.*; + +class T6762569b { + void m(T t, List> list) {} + + void test(List> list) { + m("", list); + } +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/generics/wildcards/T6732484.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/generics/wildcards/T6732484.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,37 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6732484 + * @summary Bound error on wildcard code + * @author Maurizio Cimadamore + * @compile T6732484.java + */ + +class T6732484 { + class A> {} + class B extends A {} + + A f; +} \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/varargs/T6746184.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/varargs/T6746184.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,39 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/* + * @test + * @bug 6746184 + * @summary javac fails to compile call to public varargs method + */ + +public class T6746184 { + public static void main(String[] args) { + A.m(new Object()); + } +} + +class A { + public static void m(final Object... varargs) {} + private static void m(final Object singleArg) {} +} \ No newline at end of file diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javac/warnings/T6763518.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/warnings/T6763518.java Fri Nov 07 11:45:49 2008 -0800 @@ -0,0 +1,41 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +/** + * @test + * @bug 6763518 + * @summary Impossible to suppress raw-type warnings + * @compile -Werror -Xlint:rawtypes T6763518.java + */ + +import java.util.List; + +class T6763518 { + @SuppressWarnings("rawtypes") + List l1; + + void m(@SuppressWarnings("rawtypes") List l2) { + @SuppressWarnings("rawtypes") + List l3; + }; +} diff -r 1b144d394c43 -r 5db12b3a75ea langtools/test/tools/javap/ListTest.java --- a/langtools/test/tools/javap/ListTest.java Thu Nov 06 12:10:41 2008 -0800 +++ b/langtools/test/tools/javap/ListTest.java Fri Nov 07 11:45:49 2008 -0800 @@ -82,16 +82,16 @@ String[] args = new String[options.size() + 1]; options.toArray(args); args[args.length - 1] = testClassName; - String oldOut = runOldJavap(args); - String newOut = runNewJavap(args); - boolean ok = oldOut.equals(newOut); + byte[] oldOut = runOldJavap(args); + byte[] newOut = runNewJavap(args); + boolean ok = equal(oldOut, newOut); System.err.println((ok ? "pass" : "FAIL") + ": " + testClassName); if (!ok && viewResults) view(oldOut, newOut); return ok; } - String runOldJavap(String[] args) { + byte[] runOldJavap(String[] args) { //System.err.println("OLD: " + Arrays.asList(args)); PrintStream oldOut = System.out; ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -101,29 +101,34 @@ } finally { System.setOut(oldOut); } - return out.toString(); + return out.toByteArray(); } - String runNewJavap(String[] args) { + byte[] runNewJavap(String[] args) { String[] nArgs = new String[args.length + 2]; nArgs[0] = "-XDcompat"; nArgs[1] = "-XDignore.symbol.file"; System.arraycopy(args, 0, nArgs, 2, args.length); //System.err.println("NEW: " + Arrays.asList(nArgs)); - StringWriter out = new StringWriter(); - com.sun.tools.javap.Main.run(nArgs, new PrintWriter(out, true)); - return out.toString(); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + com.sun.tools.javap.Main.run(nArgs, + new PrintWriter(new OutputStreamWriter(out), true)); + return out.toByteArray(); } - File write(String text, String suffix) throws IOException { - File f = File.createTempFile("ListTest", suffix); - FileWriter out = new FileWriter(f); + File write(byte[] text, String suffix) throws IOException { + File f = new File("ListTest." + suffix); + FileOutputStream out = new FileOutputStream(f); out.write(text); out.close(); return f; } - void view(String oldOut, String newOut) throws Exception { + boolean equal(byte[] a1, byte[] a2) { + return Arrays.equals(a1, a2); + } + + void view(byte[] oldOut, byte[] newOut) throws Exception { File oldFile = write(oldOut, "old"); File newFile = write(newOut, "new"); List cmd = new ArrayList();