Tue, 23 Jun 2009 22:09:28 -0700
Merge
1.1 --- a/src/share/classes/com/sun/tools/classfile/AccessFlags.java Sun Jun 21 23:55:50 2009 -0700 1.2 +++ b/src/share/classes/com/sun/tools/classfile/AccessFlags.java Tue Jun 23 22:09:28 2009 -0700 1.3 @@ -58,7 +58,7 @@ 1.4 public static final int ACC_ENUM = 0x4000; // class, inner, field 1.5 public static final int ACC_MODULE = 0x8000; // class, inner, field, method 1.6 1.7 - private static enum Type { Class, InnerClass, Field, Method}; 1.8 + public static enum Kind { Class, InnerClass, Field, Method}; 1.9 1.10 AccessFlags(ClassReader cr) throws IOException { 1.11 this(cr.readUnsignedShort()); 1.12 @@ -87,11 +87,11 @@ 1.13 1.14 public Set<String> getClassModifiers() { 1.15 int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags); 1.16 - return getModifiers(f, classModifiers, Type.Class); 1.17 + return getModifiers(f, classModifiers, Kind.Class); 1.18 } 1.19 1.20 public Set<String> getClassFlags() { 1.21 - return getFlags(classFlags, Type.Class); 1.22 + return getFlags(classFlags, Kind.Class); 1.23 } 1.24 1.25 private static final int[] innerClassModifiers = { 1.26 @@ -106,11 +106,11 @@ 1.27 1.28 public Set<String> getInnerClassModifiers() { 1.29 int f = ((flags & ACC_INTERFACE) != 0 ? flags & ~ACC_ABSTRACT : flags); 1.30 - return getModifiers(f, innerClassModifiers, Type.InnerClass); 1.31 + return getModifiers(f, innerClassModifiers, Kind.InnerClass); 1.32 } 1.33 1.34 public Set<String> getInnerClassFlags() { 1.35 - return getFlags(innerClassFlags, Type.InnerClass); 1.36 + return getFlags(innerClassFlags, Kind.InnerClass); 1.37 } 1.38 1.39 private static final int[] fieldModifiers = { 1.40 @@ -124,11 +124,11 @@ 1.41 }; 1.42 1.43 public Set<String> getFieldModifiers() { 1.44 - return getModifiers(fieldModifiers, Type.Field); 1.45 + return getModifiers(fieldModifiers, Kind.Field); 1.46 } 1.47 1.48 public Set<String> getFieldFlags() { 1.49 - return getFlags(fieldFlags, Type.Field); 1.50 + return getFlags(fieldFlags, Kind.Field); 1.51 } 1.52 1.53 private static final int[] methodModifiers = { 1.54 @@ -143,18 +143,18 @@ 1.55 }; 1.56 1.57 public Set<String> getMethodModifiers() { 1.58 - return getModifiers(methodModifiers, Type.Method); 1.59 + return getModifiers(methodModifiers, Kind.Method); 1.60 } 1.61 1.62 public Set<String> getMethodFlags() { 1.63 - return getFlags(methodFlags, Type.Method); 1.64 + return getFlags(methodFlags, Kind.Method); 1.65 } 1.66 1.67 - private Set<String> getModifiers(int[] modifierFlags, Type t) { 1.68 + private Set<String> getModifiers(int[] modifierFlags, Kind t) { 1.69 return getModifiers(flags, modifierFlags, t); 1.70 } 1.71 1.72 - private static Set<String> getModifiers(int flags, int[] modifierFlags, Type t) { 1.73 + private static Set<String> getModifiers(int flags, int[] modifierFlags, Kind t) { 1.74 Set<String> s = new LinkedHashSet<String>(); 1.75 for (int m: modifierFlags) { 1.76 if ((flags & m) != 0) 1.77 @@ -163,7 +163,7 @@ 1.78 return s; 1.79 } 1.80 1.81 - private Set<String> getFlags(int[] expectedFlags, Type t) { 1.82 + private Set<String> getFlags(int[] expectedFlags, Kind t) { 1.83 Set<String> s = new LinkedHashSet<String>(); 1.84 int f = flags; 1.85 for (int e: expectedFlags) { 1.86 @@ -180,7 +180,7 @@ 1.87 return s; 1.88 } 1.89 1.90 - private static String flagToModifier(int flag, Type t) { 1.91 + private static String flagToModifier(int flag, Kind t) { 1.92 switch (flag) { 1.93 case ACC_PUBLIC: 1.94 return "public"; 1.95 @@ -195,7 +195,7 @@ 1.96 case ACC_SYNCHRONIZED: 1.97 return "synchronized"; 1.98 case 0x80: 1.99 - return (t == Type.Field ? "transient" : null); 1.100 + return (t == Kind.Field ? "transient" : null); 1.101 case ACC_VOLATILE: 1.102 return "volatile"; 1.103 case ACC_NATIVE: 1.104 @@ -211,7 +211,7 @@ 1.105 } 1.106 } 1.107 1.108 - private static String flagToName(int flag, Type t) { 1.109 + private static String flagToName(int flag, Kind t) { 1.110 switch (flag) { 1.111 case ACC_PUBLIC: 1.112 return "ACC_PUBLIC"; 1.113 @@ -224,11 +224,11 @@ 1.114 case ACC_FINAL: 1.115 return "ACC_FINAL"; 1.116 case 0x20: 1.117 - return (t == Type.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED"); 1.118 + return (t == Kind.Class ? "ACC_SUPER" : "ACC_SYNCHRONIZED"); 1.119 case 0x40: 1.120 - return (t == Type.Field ? "ACC_VOLATILE" : "ACC_BRIDGE"); 1.121 + return (t == Kind.Field ? "ACC_VOLATILE" : "ACC_BRIDGE"); 1.122 case 0x80: 1.123 - return (t == Type.Field ? "ACC_TRANSIENT" : "ACC_VARARGS"); 1.124 + return (t == Kind.Field ? "ACC_TRANSIENT" : "ACC_VARARGS"); 1.125 case ACC_NATIVE: 1.126 return "ACC_NATIVE"; 1.127 case ACC_INTERFACE: 1.128 @@ -250,5 +250,5 @@ 1.129 } 1.130 } 1.131 1.132 - final int flags; 1.133 + public final int flags; 1.134 }
2.1 --- a/src/share/classes/com/sun/tools/classfile/ConstantPool.java Sun Jun 21 23:55:50 2009 -0700 2.2 +++ b/src/share/classes/com/sun/tools/classfile/ConstantPool.java Tue Jun 23 22:09:28 2009 -0700 2.3 @@ -573,6 +573,11 @@ 2.4 return visitor.visitNameAndType(this, data); 2.5 } 2.6 2.7 + @Override 2.8 + public String toString() { 2.9 + return "CONSTANT_NameAndType_info[name_index: " + name_index + ", type_index: " + type_index + "]"; 2.10 + } 2.11 + 2.12 public final int name_index; 2.13 public final int type_index; 2.14 } 2.15 @@ -600,6 +605,11 @@ 2.16 return visitor.visitString(this, data); 2.17 } 2.18 2.19 + @Override 2.20 + public String toString() { 2.21 + return "CONSTANT_String_info[class_index: " + string_index + "]"; 2.22 + } 2.23 + 2.24 public final int string_index; 2.25 } 2.26 2.27 @@ -618,7 +628,19 @@ 2.28 2.29 @Override 2.30 public String toString() { 2.31 - return "CONSTANT_Utf8_info[value: " + value + "]"; 2.32 + if (value.length() < 32 && isPrintableAscii(value)) 2.33 + return "CONSTANT_Utf8_info[value: \"" + value + "\"]"; 2.34 + else 2.35 + return "CONSTANT_Utf8_info[value: (" + value.length() + " chars)]"; 2.36 + } 2.37 + 2.38 + static boolean isPrintableAscii(String s) { 2.39 + for (int i = 0; i < s.length(); i++) { 2.40 + char c = s.charAt(i); 2.41 + if (c < 32 || c >= 127) 2.42 + return false; 2.43 + } 2.44 + return true; 2.45 } 2.46 2.47 public <R, D> R accept(Visitor<R, D> visitor, D data) {
3.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Sun Jun 21 23:55:50 2009 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Tue Jun 23 22:09:28 2009 -0700 3.3 @@ -1066,6 +1066,21 @@ 3.4 return qtype.isErroneous(); 3.5 } 3.6 3.7 + /** 3.8 + * Replaces this ForAll's typevars with a set of concrete Java types 3.9 + * and returns the instantiated generic type. Subclasses might override 3.10 + * in order to check that the list of types is a valid instantiation 3.11 + * of the ForAll's typevars. 3.12 + * 3.13 + * @param actuals list of actual types 3.14 + * @param types types instance 3.15 + * @return qtype where all occurrences of tvars are replaced 3.16 + * by types in actuals 3.17 + */ 3.18 + public Type inst(List<Type> actuals, Types types) { 3.19 + return types.subst(qtype, tvars, actuals); 3.20 + } 3.21 + 3.22 public Type map(Mapping f) { 3.23 return f.apply(qtype); 3.24 }
4.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Sun Jun 21 23:55:50 2009 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jun 23 22:09:28 2009 -0700 4.3 @@ -343,6 +343,14 @@ 4.4 if (s.tag >= firstPartialTag) 4.5 return isSuperType(s, t); 4.6 4.7 + if (s.isCompound()) { 4.8 + for (Type s2 : interfaces(s).prepend(supertype(s))) { 4.9 + if (!isSubtype(t, s2, capture)) 4.10 + return false; 4.11 + } 4.12 + return true; 4.13 + } 4.14 + 4.15 Type lower = lowerBound(s); 4.16 if (s != lower) 4.17 return isSubtype(capture ? capture(t) : t, lower, false); 4.18 @@ -2870,6 +2878,14 @@ 4.19 /** 4.20 * Capture conversion as specified by JLS 3rd Ed. 4.21 */ 4.22 + 4.23 + public List<Type> capture(List<Type> ts) { 4.24 + List<Type> buf = List.nil(); 4.25 + for (Type t : ts) { 4.26 + buf = buf.prepend(capture(t)); 4.27 + } 4.28 + return buf.reverse(); 4.29 + } 4.30 public Type capture(Type t) { 4.31 if (t.tag != CLASS) 4.32 return t;
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Sun Jun 21 23:55:50 2009 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Jun 23 22:09:28 2009 -0700 5.3 @@ -391,6 +391,10 @@ 5.4 diags.fragment("incompatible.types" + (d!=null ? ".1" : ""), d), 5.5 t, pt); 5.6 } 5.7 + } catch (Infer.InvalidInstanceException ex) { 5.8 + JCDiagnostic d = ex.getDiagnostic(); 5.9 + log.error(pos, "invalid.inferred.types", t.tvars, d); 5.10 + return types.createErrorType(pt); 5.11 } 5.12 } 5.13 }
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Sun Jun 21 23:55:50 2009 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Jun 23 22:09:28 2009 -0700 6.3 @@ -29,6 +29,7 @@ 6.4 import com.sun.tools.javac.util.List; 6.5 import com.sun.tools.javac.code.*; 6.6 import com.sun.tools.javac.code.Type.*; 6.7 +import com.sun.tools.javac.code.Symbol.*; 6.8 import com.sun.tools.javac.util.JCDiagnostic; 6.9 6.10 import static com.sun.tools.javac.code.TypeTags.*; 6.11 @@ -49,6 +50,7 @@ 6.12 6.13 Symtab syms; 6.14 Types types; 6.15 + Resolve rs; 6.16 JCDiagnostic.Factory diags; 6.17 6.18 public static Infer instance(Context context) { 6.19 @@ -62,48 +64,60 @@ 6.20 context.put(inferKey, this); 6.21 syms = Symtab.instance(context); 6.22 types = Types.instance(context); 6.23 + rs = Resolve.instance(context); 6.24 diags = JCDiagnostic.Factory.instance(context); 6.25 ambiguousNoInstanceException = 6.26 new NoInstanceException(true, diags); 6.27 unambiguousNoInstanceException = 6.28 new NoInstanceException(false, diags); 6.29 + invalidInstanceException = 6.30 + new InvalidInstanceException(diags); 6.31 + 6.32 } 6.33 6.34 - public static class NoInstanceException extends RuntimeException { 6.35 + public static class InferenceException extends RuntimeException { 6.36 private static final long serialVersionUID = 0; 6.37 6.38 - boolean isAmbiguous; // exist several incomparable best instances? 6.39 - 6.40 JCDiagnostic diagnostic; 6.41 JCDiagnostic.Factory diags; 6.42 6.43 - NoInstanceException(boolean isAmbiguous, JCDiagnostic.Factory diags) { 6.44 + InferenceException(JCDiagnostic.Factory diags) { 6.45 this.diagnostic = null; 6.46 - this.isAmbiguous = isAmbiguous; 6.47 this.diags = diags; 6.48 } 6.49 - NoInstanceException setMessage(String key) { 6.50 - this.diagnostic = diags.fragment(key); 6.51 + 6.52 + InferenceException setMessage(String key, Object... args) { 6.53 + this.diagnostic = diags.fragment(key, args); 6.54 return this; 6.55 } 6.56 - NoInstanceException setMessage(String key, Object arg1) { 6.57 - this.diagnostic = diags.fragment(key, arg1); 6.58 - return this; 6.59 - } 6.60 - NoInstanceException setMessage(String key, Object arg1, Object arg2) { 6.61 - this.diagnostic = diags.fragment(key, arg1, arg2); 6.62 - return this; 6.63 - } 6.64 - NoInstanceException setMessage(String key, Object arg1, Object arg2, Object arg3) { 6.65 - this.diagnostic = diags.fragment(key, arg1, arg2, arg3); 6.66 - return this; 6.67 - } 6.68 + 6.69 public JCDiagnostic getDiagnostic() { 6.70 - return diagnostic; 6.71 + return diagnostic; 6.72 + } 6.73 + } 6.74 + 6.75 + public static class NoInstanceException extends InferenceException { 6.76 + private static final long serialVersionUID = 1; 6.77 + 6.78 + boolean isAmbiguous; // exist several incomparable best instances? 6.79 + 6.80 + NoInstanceException(boolean isAmbiguous, JCDiagnostic.Factory diags) { 6.81 + super(diags); 6.82 + this.isAmbiguous = isAmbiguous; 6.83 } 6.84 } 6.85 + 6.86 + public static class InvalidInstanceException extends InferenceException { 6.87 + private static final long serialVersionUID = 2; 6.88 + 6.89 + InvalidInstanceException(JCDiagnostic.Factory diags) { 6.90 + super(diags); 6.91 + } 6.92 + } 6.93 + 6.94 private final NoInstanceException ambiguousNoInstanceException; 6.95 private final NoInstanceException unambiguousNoInstanceException; 6.96 + private final InvalidInstanceException invalidInstanceException; 6.97 6.98 /*************************************************************************** 6.99 * Auxiliary type values and classes 6.100 @@ -158,8 +172,7 @@ 6.101 that.inst = types.glb(that.hibounds); 6.102 } 6.103 if (that.inst == null || 6.104 - that.inst.isErroneous() || 6.105 - !types.isSubtypeUnchecked(that.inst, that.hibounds, warn)) 6.106 + that.inst.isErroneous()) 6.107 throw ambiguousNoInstanceException 6.108 .setMessage("no.unique.maximal.instance.exists", 6.109 that.qtype, that.hibounds); 6.110 @@ -234,7 +247,7 @@ 6.111 */ 6.112 public Type instantiateExpr(ForAll that, 6.113 Type to, 6.114 - Warner warn) throws NoInstanceException { 6.115 + Warner warn) throws InferenceException { 6.116 List<Type> undetvars = Type.map(that.tvars, fromTypeVarFun); 6.117 for (List<Type> l = undetvars; l.nonEmpty(); l = l.tail) { 6.118 UndetVar v = (UndetVar) l.head; 6.119 @@ -260,8 +273,7 @@ 6.120 List<Type> targs = Type.map(undetvars, getInstFun); 6.121 targs = types.subst(targs, that.tvars, targs); 6.122 checkWithinBounds(that.tvars, targs, warn); 6.123 - 6.124 - return getInstFun.apply(qtype1); 6.125 + return that.inst(targs, types); 6.126 } 6.127 6.128 /** Instantiate method type `mt' by finding instantiations of 6.129 @@ -269,36 +281,42 @@ 6.130 */ 6.131 public Type instantiateMethod(List<Type> tvars, 6.132 MethodType mt, 6.133 - List<Type> argtypes, 6.134 - boolean allowBoxing, 6.135 - boolean useVarargs, 6.136 - Warner warn) throws NoInstanceException { 6.137 + final List<Type> argtypes, 6.138 + final boolean allowBoxing, 6.139 + final boolean useVarargs, 6.140 + final Warner warn) throws InferenceException { 6.141 //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG 6.142 List<Type> undetvars = Type.map(tvars, fromTypeVarFun); 6.143 List<Type> formals = mt.argtypes; 6.144 - 6.145 + //need to capture exactly once - otherwise subsequent 6.146 + //applicability checks might fail 6.147 + final List<Type> capturedArgs = types.capture(argtypes); 6.148 + List<Type> actuals = capturedArgs; 6.149 + List<Type> actualsNoCapture = argtypes; 6.150 // instantiate all polymorphic argument types and 6.151 // set up lower bounds constraints for undetvars 6.152 Type varargsFormal = useVarargs ? formals.last() : null; 6.153 - while (argtypes.nonEmpty() && formals.head != varargsFormal) { 6.154 - Type ft = formals.head; 6.155 - Type at = argtypes.head.baseType(); 6.156 - if (at.tag == FORALL) 6.157 - at = instantiateArg((ForAll) at, ft, tvars, warn); 6.158 - Type sft = types.subst(ft, tvars, undetvars); 6.159 + while (actuals.nonEmpty() && formals.head != varargsFormal) { 6.160 + Type formal = formals.head; 6.161 + Type actual = actuals.head.baseType(); 6.162 + Type actualNoCapture = actualsNoCapture.head.baseType(); 6.163 + if (actual.tag == FORALL) 6.164 + actual = instantiateArg((ForAll)actual, formal, tvars, warn); 6.165 + Type undetFormal = types.subst(formal, tvars, undetvars); 6.166 boolean works = allowBoxing 6.167 - ? types.isConvertible(at, sft, warn) 6.168 - : types.isSubtypeUnchecked(at, sft, warn); 6.169 + ? types.isConvertible(actual, undetFormal, warn) 6.170 + : types.isSubtypeUnchecked(actual, undetFormal, warn); 6.171 if (!works) { 6.172 throw unambiguousNoInstanceException 6.173 .setMessage("no.conforming.assignment.exists", 6.174 - tvars, at, ft); 6.175 + tvars, actualNoCapture, formal); 6.176 } 6.177 formals = formals.tail; 6.178 - argtypes = argtypes.tail; 6.179 + actuals = actuals.tail; 6.180 + actualsNoCapture = actualsNoCapture.tail; 6.181 } 6.182 if (formals.head != varargsFormal || // not enough args 6.183 - !useVarargs && argtypes.nonEmpty()) { // too many args 6.184 + !useVarargs && actuals.nonEmpty()) { // too many args 6.185 // argument lists differ in length 6.186 throw unambiguousNoInstanceException 6.187 .setMessage("arg.length.mismatch"); 6.188 @@ -306,20 +324,21 @@ 6.189 6.190 // for varargs arguments as well 6.191 if (useVarargs) { 6.192 - Type elt = types.elemtype(varargsFormal); 6.193 - Type sft = types.subst(elt, tvars, undetvars); 6.194 - while (argtypes.nonEmpty()) { 6.195 - Type ft = sft; 6.196 - Type at = argtypes.head.baseType(); 6.197 - if (at.tag == FORALL) 6.198 - at = instantiateArg((ForAll) at, ft, tvars, warn); 6.199 - boolean works = types.isConvertible(at, sft, warn); 6.200 + Type elemType = types.elemtype(varargsFormal); 6.201 + Type elemUndet = types.subst(elemType, tvars, undetvars); 6.202 + while (actuals.nonEmpty()) { 6.203 + Type actual = actuals.head.baseType(); 6.204 + Type actualNoCapture = actualsNoCapture.head.baseType(); 6.205 + if (actual.tag == FORALL) 6.206 + actual = instantiateArg((ForAll)actual, elemType, tvars, warn); 6.207 + boolean works = types.isConvertible(actual, elemUndet, warn); 6.208 if (!works) { 6.209 throw unambiguousNoInstanceException 6.210 .setMessage("no.conforming.assignment.exists", 6.211 - tvars, at, ft); 6.212 + tvars, actualNoCapture, elemType); 6.213 } 6.214 - argtypes = argtypes.tail; 6.215 + actuals = actuals.tail; 6.216 + actualsNoCapture = actualsNoCapture.tail; 6.217 } 6.218 } 6.219 6.220 @@ -350,16 +369,38 @@ 6.221 } 6.222 checkWithinBounds(tvars, undettypes.toList(), warn); 6.223 6.224 + mt = (MethodType)types.subst(mt, tvars, insttypes.toList()); 6.225 + 6.226 if (!restvars.isEmpty()) { 6.227 // if there are uninstantiated variables, 6.228 // quantify result type with them 6.229 - mt = new MethodType(mt.argtypes, 6.230 - new ForAll(restvars.toList(), mt.restype), 6.231 - mt.thrown, syms.methodClass); 6.232 + final List<Type> inferredTypes = insttypes.toList(); 6.233 + final List<Type> all_tvars = tvars; //this is the wrong tvars 6.234 + final MethodType mt2 = new MethodType(mt.argtypes, null, mt.thrown, syms.methodClass); 6.235 + mt2.restype = new ForAll(restvars.toList(), mt.restype) { 6.236 + @Override 6.237 + public Type inst(List<Type> inferred, Types types) throws NoInstanceException { 6.238 + List<Type> formals = types.subst(mt2.argtypes, tvars, inferred); 6.239 + if (!rs.argumentsAcceptable(capturedArgs, formals, 6.240 + allowBoxing, useVarargs, warn)) { 6.241 + // inferred method is not applicable 6.242 + throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", formals, argtypes); 6.243 + } 6.244 + // check that inferred bounds conform to their bounds 6.245 + checkWithinBounds(all_tvars, 6.246 + types.subst(inferredTypes, tvars, inferred), warn); 6.247 + return super.inst(inferred, types); 6.248 + }}; 6.249 + return mt2; 6.250 } 6.251 - 6.252 - // return instantiated version of method type 6.253 - return types.subst(mt, tvars, insttypes.toList()); 6.254 + else if (!rs.argumentsAcceptable(capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn)) { 6.255 + // inferred method is not applicable 6.256 + throw invalidInstanceException.setMessage("inferred.do.not.conform.to.params", mt.getParameterTypes(), argtypes); 6.257 + } 6.258 + else { 6.259 + // return instantiated version of method type 6.260 + return mt; 6.261 + } 6.262 } 6.263 //where 6.264 6.265 @@ -371,7 +412,7 @@ 6.266 private Type instantiateArg(ForAll that, 6.267 Type to, 6.268 List<Type> tvars, 6.269 - Warner warn) throws NoInstanceException { 6.270 + Warner warn) throws InferenceException { 6.271 List<Type> targs; 6.272 try { 6.273 return instantiateExpr(that, to, warn); 6.274 @@ -388,16 +429,16 @@ 6.275 private void checkWithinBounds(List<Type> tvars, 6.276 List<Type> arguments, 6.277 Warner warn) 6.278 - throws NoInstanceException { 6.279 + throws InvalidInstanceException { 6.280 for (List<Type> tvs = tvars, args = arguments; 6.281 tvs.nonEmpty(); 6.282 tvs = tvs.tail, args = args.tail) { 6.283 if (args.head instanceof UndetVar) continue; 6.284 List<Type> bounds = types.subst(types.getBounds((TypeVar)tvs.head), tvars, arguments); 6.285 if (!types.isSubtypeUnchecked(args.head, bounds, warn)) 6.286 - throw unambiguousNoInstanceException 6.287 + throw invalidInstanceException 6.288 .setMessage("inferred.do.not.conform.to.bounds", 6.289 - arguments, tvars); 6.290 + args.head, bounds); 6.291 } 6.292 } 6.293 }
7.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Sun Jun 21 23:55:50 2009 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Jun 23 22:09:28 2009 -0700 7.3 @@ -299,7 +299,7 @@ 7.4 boolean allowBoxing, 7.5 boolean useVarargs, 7.6 Warner warn) 7.7 - throws Infer.NoInstanceException { 7.8 + throws Infer.InferenceException { 7.9 if (useVarargs && (m.flags() & VARARGS) == 0) return null; 7.10 Type mt = types.memberType(site, m); 7.11 7.12 @@ -370,7 +370,7 @@ 7.13 try { 7.14 return rawInstantiate(env, site, m, argtypes, typeargtypes, 7.15 allowBoxing, useVarargs, warn); 7.16 - } catch (Infer.NoInstanceException ex) { 7.17 + } catch (Infer.InferenceException ex) { 7.18 return null; 7.19 } 7.20 } 7.21 @@ -584,7 +584,7 @@ 7.22 default: return bestSoFar; 7.23 } 7.24 } 7.25 - } catch (Infer.NoInstanceException ex) { 7.26 + } catch (Infer.InferenceException ex) { 7.27 switch (bestSoFar.kind) { 7.28 case ABSENT_MTH: 7.29 return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
8.1 --- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Sun Jun 21 23:55:50 2009 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Jun 23 22:09:28 2009 -0700 8.3 @@ -1521,9 +1521,9 @@ 8.4 int acount = 0; 8.5 8.6 boolean sigReq = 8.7 - typarams.length() != 0 || supertype.getTypeArguments().length() != 0; 8.8 + typarams.length() != 0 || supertype.allparams().length() != 0; 8.9 for (List<Type> l = interfaces; !sigReq && l.nonEmpty(); l = l.tail) 8.10 - sigReq = l.head.getTypeArguments().length() != 0; 8.11 + sigReq = l.head.allparams().length() != 0; 8.12 if (sigReq) { 8.13 assert source.allowGenerics(); 8.14 int alenIdx = writeAttr(names.Signature);
9.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Sun Jun 21 23:55:50 2009 -0700 9.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Jun 23 22:09:28 2009 -0700 9.3 @@ -84,7 +84,7 @@ 9.4 {0} {1} in {4} {5} cannot be applied to given types\n\ 9.5 required: {2}\n\ 9.6 found: {3} 9.7 - compiler.err.cant.apply.symbol.1=\ 9.8 +compiler.err.cant.apply.symbol.1=\ 9.9 {0} {1} in {4} {5} cannot be applied to given types;\n\ 9.10 required: {2}\n\ 9.11 found: {3}\n\ 9.12 @@ -469,6 +469,8 @@ 9.13 type parameters of {0} cannot be determined 9.14 compiler.err.undetermined.type.1=\ 9.15 type parameters of {0} cannot be determined; {1} 9.16 +compiler.err.invalid.inferred.types=\ 9.17 + invalid inferred types for {0}; {1} 9.18 compiler.err.unreachable.stmt=\ 9.19 unreachable statement 9.20 compiler.err.initializer.must.be.able.to.complete.normally=\ 9.21 @@ -995,7 +997,13 @@ 9.22 compiler.misc.arg.length.mismatch=\ 9.23 cannot instantiate from arguments because actual and formal argument lists differ in length 9.24 compiler.misc.inferred.do.not.conform.to.bounds=\ 9.25 - inferred type argument(s) {0} do not conform to bounds of type variable(s) {1} 9.26 + inferred type does not conform to declared bound(s)\n\ 9.27 + inferred: {0}\n\ 9.28 + bound(s): {1} 9.29 +compiler.misc.inferred.do.not.conform.to.params=\ 9.30 + actual arguments do not conforms to inferred formal arguments\n\ 9.31 + required: {0}\n\ 9.32 + found: {1} 9.33 9.34 ##### 9.35
10.1 --- a/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Sun Jun 21 23:55:50 2009 -0700 10.2 +++ b/src/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java Tue Jun 23 22:09:28 2009 -0700 10.3 @@ -172,9 +172,6 @@ 10.4 return formatIterable(d, (Iterable<?>)arg, l); 10.5 } 10.6 else if (arg instanceof Type) { 10.7 - if (!allCaptured.contains(arg)) { 10.8 - allCaptured = allCaptured.append((Type)arg); 10.9 - } 10.10 return printer.visit((Type)arg, l); 10.11 } 10.12 else if (arg instanceof Symbol) { 10.13 @@ -482,5 +479,12 @@ 10.14 protected String capturedVarId(CapturedType t, Locale locale) { 10.15 return "" + (allCaptured.indexOf(t) + 1); 10.16 } 10.17 + @Override 10.18 + public String visitCapturedType(CapturedType t, Locale locale) { 10.19 + if (!allCaptured.contains(t)) { 10.20 + allCaptured = allCaptured.append(t); 10.21 + } 10.22 + return super.visitCapturedType(t, locale); 10.23 + } 10.24 }; 10.25 }
11.1 --- a/src/share/classes/com/sun/tools/javap/AttributeWriter.java Sun Jun 21 23:55:50 2009 -0700 11.2 +++ b/src/share/classes/com/sun/tools/javap/AttributeWriter.java Tue Jun 23 22:09:28 2009 -0700 11.3 @@ -74,7 +74,7 @@ 11.4 public class AttributeWriter extends BasicWriter 11.5 implements Attribute.Visitor<Void,Void> 11.6 { 11.7 - static AttributeWriter instance(Context context) { 11.8 + public static AttributeWriter instance(Context context) { 11.9 AttributeWriter instance = context.get(AttributeWriter.class); 11.10 if (instance == null) 11.11 instance = new AttributeWriter(context);
12.1 --- a/src/share/classes/com/sun/tools/javap/ClassWriter.java Sun Jun 21 23:55:50 2009 -0700 12.2 +++ b/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue Jun 23 22:09:28 2009 -0700 12.3 @@ -93,17 +93,25 @@ 12.4 this.lastModified = lastModified; 12.5 } 12.6 12.7 - ClassFile getClassFile() { 12.8 + protected ClassFile getClassFile() { 12.9 return classFile; 12.10 } 12.11 12.12 - Method getMethod() { 12.13 + protected void setClassFile(ClassFile cf) { 12.14 + classFile = cf; 12.15 + constant_pool = classFile.constant_pool; 12.16 + } 12.17 + 12.18 + protected Method getMethod() { 12.19 return method; 12.20 } 12.21 12.22 + protected void setMethod(Method m) { 12.23 + method = m; 12.24 + } 12.25 + 12.26 public void write(ClassFile cf) { 12.27 - classFile = cf; 12.28 - constant_pool = classFile.constant_pool; 12.29 + setClassFile(cf); 12.30 12.31 if ((options.sysInfo || options.verbose) && !options.compat) { 12.32 if (uri != null) { 12.33 @@ -197,13 +205,13 @@ 12.34 println(); 12.35 } 12.36 12.37 - void writeFields() { 12.38 + protected void writeFields() { 12.39 for (Field f: classFile.fields) { 12.40 writeField(f); 12.41 } 12.42 } 12.43 12.44 - void writeField(Field f) { 12.45 + protected void writeField(Field f) { 12.46 if (!options.checkAccess(f.access_flags)) 12.47 return; 12.48 12.49 @@ -259,12 +267,12 @@ 12.50 println(); 12.51 } 12.52 12.53 - void writeMethods() { 12.54 + protected void writeMethods() { 12.55 for (Method m: classFile.methods) 12.56 writeMethod(m); 12.57 } 12.58 12.59 - void writeMethod(Method m) { 12.60 + protected void writeMethod(Method m) { 12.61 if (!options.checkAccess(m.access_flags)) 12.62 return; 12.63
13.1 --- a/src/share/classes/com/sun/tools/javap/ConstantWriter.java Sun Jun 21 23:55:50 2009 -0700 13.2 +++ b/src/share/classes/com/sun/tools/javap/ConstantWriter.java Tue Jun 23 22:09:28 2009 -0700 13.3 @@ -40,7 +40,7 @@ 13.4 * deletion without notice.</b> 13.5 */ 13.6 public class ConstantWriter extends BasicWriter { 13.7 - static ConstantWriter instance(Context context) { 13.8 + public static ConstantWriter instance(Context context) { 13.9 ConstantWriter instance = context.get(ConstantWriter.class); 13.10 if (instance == null) 13.11 instance = new ConstantWriter(context); 13.12 @@ -54,7 +54,12 @@ 13.13 options = Options.instance(context); 13.14 } 13.15 13.16 - void writeConstantPool() { 13.17 + protected void writeConstantPool() { 13.18 + ConstantPool constant_pool = classWriter.getClassFile().constant_pool; 13.19 + writeConstantPool(constant_pool); 13.20 + } 13.21 + 13.22 + protected void writeConstantPool(ConstantPool constant_pool) { 13.23 ConstantPool.Visitor<Integer, Void> v = new ConstantPool.Visitor<Integer,Void>() { 13.24 public Integer visitClass(CONSTANT_Class_info info, Void p) { 13.25 println("#" + info.name_index + ";\t// " + stringValue(info)); 13.26 @@ -114,7 +119,6 @@ 13.27 13.28 }; 13.29 println(" Constant pool:"); 13.30 - ConstantPool constant_pool = classWriter.getClassFile().constant_pool; 13.31 int cpx = 1; 13.32 while (cpx < constant_pool.size()) { 13.33 try { 13.34 @@ -127,7 +131,7 @@ 13.35 } 13.36 } 13.37 13.38 - void write(int cpx) { 13.39 + protected void write(int cpx) { 13.40 ClassFile classFile = classWriter.getClassFile(); 13.41 if (cpx == 0) { 13.42 print("#0");
14.1 --- a/src/share/classes/com/sun/tools/javap/JavapTask.java Sun Jun 21 23:55:50 2009 -0700 14.2 +++ b/src/share/classes/com/sun/tools/javap/JavapTask.java Tue Jun 23 22:09:28 2009 -0700 14.3 @@ -36,6 +36,7 @@ 14.4 import java.io.Writer; 14.5 import java.security.DigestInputStream; 14.6 import java.security.MessageDigest; 14.7 +import java.security.NoSuchAlgorithmException; 14.8 import java.text.MessageFormat; 14.9 import java.util.ArrayList; 14.10 import java.util.Arrays; 14.11 @@ -298,21 +299,28 @@ 14.12 14.13 }; 14.14 14.15 - JavapTask() { 14.16 + public JavapTask() { 14.17 context = new Context(); 14.18 context.put(Messages.class, this); 14.19 options = Options.instance(context); 14.20 + attributeFactory = new Attribute.Factory(); 14.21 } 14.22 14.23 - JavapTask(Writer out, 14.24 + public JavapTask(Writer out, 14.25 + JavaFileManager fileManager, 14.26 + DiagnosticListener<? super JavaFileObject> diagnosticListener) { 14.27 + this(); 14.28 + this.log = getPrintWriterForWriter(out); 14.29 + this.fileManager = fileManager; 14.30 + this.diagnosticListener = diagnosticListener; 14.31 + } 14.32 + 14.33 + public JavapTask(Writer out, 14.34 JavaFileManager fileManager, 14.35 DiagnosticListener<? super JavaFileObject> diagnosticListener, 14.36 Iterable<String> options, 14.37 Iterable<String> classes) { 14.38 - this(); 14.39 - this.log = getPrintWriterForWriter(out); 14.40 - this.fileManager = fileManager; 14.41 - this.diagnosticListener = diagnosticListener; 14.42 + this(out, fileManager, diagnosticListener); 14.43 14.44 try { 14.45 handleOptions(options, false); 14.46 @@ -553,29 +561,10 @@ 14.47 continue; 14.48 } 14.49 } 14.50 - Attribute.Factory attributeFactory = new Attribute.Factory(); 14.51 attributeFactory.setCompat(options.compat); 14.52 attributeFactory.setJSR277(options.jsr277); 14.53 14.54 - InputStream in = fo.openInputStream(); 14.55 - SizeInputStream sizeIn = null; 14.56 - MessageDigest md = null; 14.57 - if (options.sysInfo || options.verbose) { 14.58 - md = MessageDigest.getInstance("MD5"); 14.59 - in = new DigestInputStream(in, md); 14.60 - in = sizeIn = new SizeInputStream(in); 14.61 - } 14.62 - 14.63 - ClassFile cf = ClassFile.read(in, attributeFactory); 14.64 - 14.65 - if (options.sysInfo || options.verbose) { 14.66 - classWriter.setFile(fo.toUri()); 14.67 - classWriter.setLastModified(fo.getLastModified()); 14.68 - classWriter.setDigest("MD5", md.digest()); 14.69 - classWriter.setFileSize(sizeIn.size()); 14.70 - } 14.71 - 14.72 - classWriter.write(cf); 14.73 + write(read(fo)); 14.74 14.75 } catch (ConstantPoolException e) { 14.76 diagnosticListener.report(createDiagnostic("err.bad.constant.pool", className, e.getLocalizedMessage())); 14.77 @@ -606,6 +595,103 @@ 14.78 return ok; 14.79 } 14.80 14.81 + public static class ClassFileInfo { 14.82 + ClassFileInfo(JavaFileObject fo, ClassFile cf, byte[] digest, int size) { 14.83 + this.fo = fo; 14.84 + this.cf = cf; 14.85 + this.digest = digest; 14.86 + this.size = size; 14.87 + } 14.88 + public final JavaFileObject fo; 14.89 + public final ClassFile cf; 14.90 + public final byte[] digest; 14.91 + public final int size; 14.92 + } 14.93 + 14.94 + public ClassFileInfo read(JavaFileObject fo) throws IOException, ConstantPoolException { 14.95 + InputStream in = fo.openInputStream(); 14.96 + try { 14.97 + SizeInputStream sizeIn = null; 14.98 + MessageDigest md = null; 14.99 + if (options.sysInfo || options.verbose) { 14.100 + try { 14.101 + md = MessageDigest.getInstance("MD5"); 14.102 + } catch (NoSuchAlgorithmException ignore) { 14.103 + } 14.104 + in = new DigestInputStream(in, md); 14.105 + in = sizeIn = new SizeInputStream(in); 14.106 + } 14.107 + 14.108 + ClassFile cf = ClassFile.read(in, attributeFactory); 14.109 + byte[] digest = (md == null) ? null : md.digest(); 14.110 + int size = (sizeIn == null) ? -1 : sizeIn.size(); 14.111 + return new ClassFileInfo(fo, cf, digest, size); 14.112 + } finally { 14.113 + in.close(); 14.114 + } 14.115 + } 14.116 + 14.117 + public void write(ClassFileInfo info) { 14.118 + ClassWriter classWriter = ClassWriter.instance(context); 14.119 + if (options.sysInfo || options.verbose) { 14.120 + classWriter.setFile(info.fo.toUri()); 14.121 + classWriter.setLastModified(info.fo.getLastModified()); 14.122 + classWriter.setDigest("MD5", info.digest); 14.123 + classWriter.setFileSize(info.size); 14.124 + } 14.125 + 14.126 + classWriter.write(info.cf); 14.127 + } 14.128 + 14.129 + protected void setClassFile(ClassFile classFile) { 14.130 + ClassWriter classWriter = ClassWriter.instance(context); 14.131 + classWriter.setClassFile(classFile); 14.132 + } 14.133 + 14.134 + protected void setMethod(Method enclosingMethod) { 14.135 + ClassWriter classWriter = ClassWriter.instance(context); 14.136 + classWriter.setMethod(enclosingMethod); 14.137 + } 14.138 + 14.139 + protected void write(Attribute value) { 14.140 + AttributeWriter attrWriter = AttributeWriter.instance(context); 14.141 + ClassWriter classWriter = ClassWriter.instance(context); 14.142 + ClassFile cf = classWriter.getClassFile(); 14.143 + attrWriter.write(cf, value, cf.constant_pool); 14.144 + } 14.145 + 14.146 + protected void write(Attributes attrs) { 14.147 + AttributeWriter attrWriter = AttributeWriter.instance(context); 14.148 + ClassWriter classWriter = ClassWriter.instance(context); 14.149 + ClassFile cf = classWriter.getClassFile(); 14.150 + attrWriter.write(cf, attrs, cf.constant_pool); 14.151 + } 14.152 + 14.153 + protected void write(ConstantPool constant_pool) { 14.154 + ConstantWriter constantWriter = ConstantWriter.instance(context); 14.155 + constantWriter.writeConstantPool(constant_pool); 14.156 + } 14.157 + 14.158 + protected void write(ConstantPool constant_pool, int value) { 14.159 + ConstantWriter constantWriter = ConstantWriter.instance(context); 14.160 + constantWriter.write(value); 14.161 + } 14.162 + 14.163 + protected void write(ConstantPool.CPInfo value) { 14.164 + ConstantWriter constantWriter = ConstantWriter.instance(context); 14.165 + constantWriter.println(value); 14.166 + } 14.167 + 14.168 + protected void write(Field value) { 14.169 + ClassWriter classWriter = ClassWriter.instance(context); 14.170 + classWriter.writeField(value); 14.171 + } 14.172 + 14.173 + protected void write(Method value) { 14.174 + ClassWriter classWriter = ClassWriter.instance(context); 14.175 + classWriter.writeMethod(value); 14.176 + } 14.177 + 14.178 private JavaFileManager getDefaultFileManager(final DiagnosticListener<? super JavaFileObject> dl, PrintWriter log) { 14.179 return JavapFileManager.create(dl, log, options); 14.180 } 14.181 @@ -735,7 +821,7 @@ 14.182 } 14.183 } 14.184 14.185 - Context context; 14.186 + protected Context context; 14.187 JavaFileManager fileManager; 14.188 PrintWriter log; 14.189 DiagnosticListener<? super JavaFileObject> diagnosticListener; 14.190 @@ -744,6 +830,7 @@ 14.191 //ResourceBundle bundle; 14.192 Locale task_locale; 14.193 Map<Locale, ResourceBundle> bundles; 14.194 + protected Attribute.Factory attributeFactory; 14.195 14.196 private static final String progname = "javap"; 14.197
15.1 --- a/src/share/classes/com/sun/tools/javap/SourceWriter.java Sun Jun 21 23:55:50 2009 -0700 15.2 +++ b/src/share/classes/com/sun/tools/javap/SourceWriter.java Tue Jun 23 22:09:28 2009 -0700 15.3 @@ -134,6 +134,9 @@ 15.4 } 15.5 15.6 private String readSource(ClassFile cf) { 15.7 + if (fileManager == null) 15.8 + return null; 15.9 + 15.10 Location location; 15.11 if (fileManager.hasLocation((StandardLocation.SOURCE_PATH))) 15.12 location = StandardLocation.SOURCE_PATH;
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/tools/javac/6835430/A.java Tue Jun 23 22:09:28 2009 -0700 16.3 @@ -0,0 +1,32 @@ 16.4 +/* 16.5 + * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 16.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 16.24 + * have any questions. 16.25 + */ 16.26 + 16.27 +class A<T extends A<T>> { 16.28 + class C { 16.29 + public T getT() { return null; } 16.30 + } 16.31 +} 16.32 + 16.33 +class B extends A<B> { 16.34 + public class D extends A<B>.C {} 16.35 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/tools/javac/6835430/T6835430.java Tue Jun 23 22:09:28 2009 -0700 17.3 @@ -0,0 +1,38 @@ 17.4 +/* 17.5 + * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 17.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 17.24 + * have any questions. 17.25 + */ 17.26 + 17.27 +/* 17.28 + * @test 17.29 + * @bug 6835430 17.30 + * @summary 6835430: javac does not generate signature attributes for classes extending parameterized inner classes 17.31 + * @author mcimadamore 17.32 + * 17.33 + * @compile A.java 17.34 + * @compile T6835430.java 17.35 + */ 17.36 + 17.37 +class T6835430 { 17.38 + void test(B.D d) { 17.39 + B b = d.getT(); 17.40 + } 17.41 +}
18.1 --- a/test/tools/javac/Diagnostics/6799605/T6799605.java Sun Jun 21 23:55:50 2009 -0700 18.2 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.java Tue Jun 23 22:09:28 2009 -0700 18.3 @@ -27,6 +27,7 @@ 18.4 * @summary Basic/Raw formatters should use type/symbol printer instead of toString() 18.5 * @author mcimadamore 18.6 * @compile/fail/ref=T6799605.out -XDrawDiagnostics T6799605.java 18.7 + * @compile/fail/ref=T6799605.out -XDoldDiags -XDrawDiagnostics T6799605.java 18.8 */ 18.9 18.10 class T6799605<X> {
19.1 --- a/test/tools/javac/Diagnostics/6799605/T6799605.out Sun Jun 21 23:55:50 2009 -0700 19.2 +++ b/test/tools/javac/Diagnostics/6799605/T6799605.out Tue Jun 23 22:09:28 2009 -0700 19.3 @@ -1,4 +1,4 @@ 19.4 -T6799605.java:39:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X> 19.5 -T6799605.java:40:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X> 19.6 -T6799605.java:41:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X> 19.7 +T6799605.java:40:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>, kindname.class, T6799605<X> 19.8 +T6799605.java:41:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>, kindname.class, T6799605<X> 19.9 +T6799605.java:42:9: compiler.err.cant.resolve.location.args: kindname.method, m, , T6799605<compiler.misc.type.captureof: 1, ?>,T6799605<compiler.misc.type.captureof: 2, ?>,T6799605<compiler.misc.type.captureof: 3, ?>, kindname.class, T6799605<X> 19.10 3 errors
20.1 --- a/test/tools/javac/generics/inference/6302954/T6476073.java Sun Jun 21 23:55:50 2009 -0700 20.2 +++ b/test/tools/javac/generics/inference/6302954/T6476073.java Tue Jun 23 22:09:28 2009 -0700 20.3 @@ -25,6 +25,7 @@ 20.4 * @test 20.5 * @bug 6476073 20.6 * @summary Capture using super wildcard of type variables doesn't work 20.7 + * @ignore awaiting for 6650759 (see bug report for a detailed evaluation) 20.8 * @compile T6476073.java 20.9 */ 20.10
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712a.java Tue Jun 23 22:09:28 2009 -0700 21.3 @@ -0,0 +1,41 @@ 21.4 +/* 21.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 21.7 + * 21.8 + * This code is free software; you can redistribute it and/or modify it 21.9 + * under the terms of the GNU General Public License version 2 only, as 21.10 + * published by the Free Software Foundation. 21.11 + * 21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 21.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 21.15 + * version 2 for more details (a copy is included in the LICENSE file that 21.16 + * accompanied this code). 21.17 + * 21.18 + * You should have received a copy of the GNU General Public License version 21.19 + * 2 along with this work; if not, write to the Free Software Foundation, 21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21.21 + * 21.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 21.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 21.24 + * have any questions. 21.25 + */ 21.26 + 21.27 +/* 21.28 + * @test 21.29 + * @bug 6638712 21.30 + * @author mcimadamore 21.31 + * @summary Inference with wildcard types causes selection of inapplicable method 21.32 + * @compile/fail/ref=T6638712a.out -XDrawDiagnostics T6638712a.java 21.33 + */ 21.34 + 21.35 +import java.util.*; 21.36 + 21.37 +class T6638712a { 21.38 + 21.39 + <T> Comparator<T> compound(Iterable<? extends Comparator<? super T>> it) {} 21.40 + 21.41 + public void test(List<Comparator<?>> x) { 21.42 + Comparator<String> c3 = compound(x); 21.43 + } 21.44 +}
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712a.out Tue Jun 23 22:09:28 2009 -0700 22.3 @@ -0,0 +1,2 @@ 22.4 +T6638712a.java:39:41: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.params: java.lang.Iterable<? extends java.util.Comparator<? super java.lang.String>>, java.util.List<java.util.Comparator<?>>) 22.5 +1 error
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712b.java Tue Jun 23 22:09:28 2009 -0700 23.3 @@ -0,0 +1,39 @@ 23.4 +/* 23.5 + * Copyright 2009 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 23.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 23.24 + * have any questions. 23.25 + */ 23.26 + 23.27 +/* 23.28 + * @test 23.29 + * @bug 6638712 23.30 + * @author mcimadamore 23.31 + * @summary Inference with wildcard types causes selection of inapplicable method 23.32 + * @compile/fail/ref=T6638712b.out -XDrawDiagnostics T6638712b.java 23.33 + */ 23.34 + 23.35 +class T6638712b<X> { 23.36 + 23.37 + <I extends T6638712b<T>, T> T m(I test) { return null; } 23.38 + 23.39 + void test(T6638712b<Integer> x) { 23.40 + String i = m(x); 23.41 + } 23.42 +}
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712b.out Tue Jun 23 22:09:28 2009 -0700 24.3 @@ -0,0 +1,2 @@ 24.4 +T6638712b.java:37:21: compiler.err.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.bounds: T6638712b<java.lang.Integer>, T6638712b<java.lang.String>) 24.5 +1 error
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712c.java Tue Jun 23 22:09:28 2009 -0700 25.3 @@ -0,0 +1,41 @@ 25.4 +/* 25.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.7 + * 25.8 + * This code is free software; you can redistribute it and/or modify it 25.9 + * under the terms of the GNU General Public License version 2 only, as 25.10 + * published by the Free Software Foundation. 25.11 + * 25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25.15 + * version 2 for more details (a copy is included in the LICENSE file that 25.16 + * accompanied this code). 25.17 + * 25.18 + * You should have received a copy of the GNU General Public License version 25.19 + * 2 along with this work; if not, write to the Free Software Foundation, 25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 25.21 + * 25.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 25.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 25.24 + * have any questions. 25.25 + */ 25.26 + 25.27 +/* 25.28 + * @test 25.29 + * @bug 6638712 6707034 25.30 + * @author mcimadamore 25.31 + * @summary Inference with wildcard types causes selection of inapplicable method 25.32 + * @compile/fail/ref=T6638712c.out -XDrawDiagnostics T6638712c.java 25.33 + */ 25.34 + 25.35 +import java.util.*; 25.36 + 25.37 +class T6638712c { 25.38 + 25.39 + <T> T sort(T[] a, Comparator<? super T> c) { return null; } 25.40 + 25.41 + void test(Enum[] e, Comparator<Enum<?>> comp) { 25.42 + sort(e, comp); 25.43 + } 25.44 +}
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712c.out Tue Jun 23 22:09:28 2009 -0700 26.3 @@ -0,0 +1,2 @@ 26.4 +T6638712c.java:39:9: compiler.err.cant.apply.symbol: kindname.method, sort, T[],java.util.Comparator<? super T>, java.lang.Enum[],java.util.Comparator<java.lang.Enum<?>>, kindname.class, T6638712c, null 26.5 +1 error
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712d.java Tue Jun 23 22:09:28 2009 -0700 27.3 @@ -0,0 +1,41 @@ 27.4 +/* 27.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 27.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 27.7 + * 27.8 + * This code is free software; you can redistribute it and/or modify it 27.9 + * under the terms of the GNU General Public License version 2 only, as 27.10 + * published by the Free Software Foundation. 27.11 + * 27.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 27.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 27.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27.15 + * version 2 for more details (a copy is included in the LICENSE file that 27.16 + * accompanied this code). 27.17 + * 27.18 + * You should have received a copy of the GNU General Public License version 27.19 + * 2 along with this work; if not, write to the Free Software Foundation, 27.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 27.21 + * 27.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 27.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 27.24 + * have any questions. 27.25 + */ 27.26 + 27.27 +/* 27.28 + * @test 27.29 + * @bug 6638712 6730468 27.30 + * @author mcimadamore 27.31 + * @summary Inference with wildcard types causes selection of inapplicable method 27.32 + * @compile/fail/ref=T6638712d.out -XDrawDiagnostics T6638712d.java 27.33 + */ 27.34 + 27.35 +import java.util.*; 27.36 + 27.37 +public class T6638712d { 27.38 + 27.39 + <U> U m(U u, List<List<U>> list) { return null; } 27.40 + 27.41 + void test(List<List<String>> lls) { 27.42 + m(1, lls); 27.43 + } 27.44 +}
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712d.out Tue Jun 23 22:09:28 2009 -0700 28.3 @@ -0,0 +1,2 @@ 28.4 +T6638712d.java:39:9: compiler.err.cant.apply.symbol: kindname.method, m, U,java.util.List<java.util.List<U>>, int,java.util.List<java.util.List<java.lang.String>>, kindname.class, T6638712d, null 28.5 +1 error
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712e.java Tue Jun 23 22:09:28 2009 -0700 29.3 @@ -0,0 +1,43 @@ 29.4 +/* 29.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 29.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 29.7 + * 29.8 + * This code is free software; you can redistribute it and/or modify it 29.9 + * under the terms of the GNU General Public License version 2 only, as 29.10 + * published by the Free Software Foundation. 29.11 + * 29.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 29.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 29.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 29.15 + * version 2 for more details (a copy is included in the LICENSE file that 29.16 + * accompanied this code). 29.17 + * 29.18 + * You should have received a copy of the GNU General Public License version 29.19 + * 2 along with this work; if not, write to the Free Software Foundation, 29.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 29.21 + * 29.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 29.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 29.24 + * have any questions. 29.25 + */ 29.26 + 29.27 +/* 29.28 + * @test 29.29 + * @bug 6638712 6795689 29.30 + * @author mcimadamore 29.31 + * @summary Inference with wildcard types causes selection of inapplicable method 29.32 + * @compile/fail/ref=T6638712e.out -XDrawDiagnostics T6638712e.java 29.33 + */ 29.34 + 29.35 +class T6638712e { 29.36 + 29.37 + static class Foo<A, B> { 29.38 + <X> Foo<X, B> m(Foo<? super X, ? extends A> foo) { return null;} 29.39 + } 29.40 + 29.41 + static class Test { 29.42 + Foo<Object, String> test(Foo<Boolean, String> foo1, Foo<Boolean, Boolean> foo2) { 29.43 + return foo1.m(foo2); 29.44 + } 29.45 + } 29.46 +}
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712e.out Tue Jun 23 22:09:28 2009 -0700 30.3 @@ -0,0 +1,2 @@ 30.4 +T6638712e.java:40:27: compiler.err.invalid.inferred.types: X, (compiler.misc.inferred.do.not.conform.to.params: T6638712e.Foo<? super java.lang.Object,? extends java.lang.Boolean>, T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>) 30.5 +1 error
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/tools/javac/generics/inference/T6835428.java Tue Jun 23 22:09:28 2009 -0700 31.3 @@ -0,0 +1,38 @@ 31.4 +/* 31.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 + * 31.8 + * This code is free software; you can redistribute it and/or modify it 31.9 + * under the terms of the GNU General Public License version 2 only, as 31.10 + * published by the Free Software Foundation. 31.11 + * 31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.15 + * version 2 for more details (a copy is included in the LICENSE file that 31.16 + * accompanied this code). 31.17 + * 31.18 + * You should have received a copy of the GNU General Public License version 31.19 + * 2 along with this work; if not, write to the Free Software Foundation, 31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.21 + * 31.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 31.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 31.24 + * have any questions. 31.25 + */ 31.26 + 31.27 +/** 31.28 + * @test 31.29 + * @bug 6835428 31.30 + * @author mcimadamore 31.31 + * @summary regression: return-type inference rejects valid code 31.32 + * @compile T6835428.java 31.33 + */ 31.34 + 31.35 +class T6835428<T> { 31.36 + interface X<T> {} 31.37 + <T extends Comparable<? super T>> T6835428<X<T>> m() { return null; } 31.38 + <T extends Comparable<? super T>> void test() { 31.39 + T6835428<X<T>> t = m(); 31.40 + } 31.41 +}