Wed, 23 Apr 2014 18:04:02 -0700
Merge
test/tools/javac/lambda/ErroneousLambdaExpr.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/lambda/ErroneousLambdaExpr.out | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Wed Apr 23 11:35:48 2014 -0700 1.2 +++ b/src/share/classes/com/sun/tools/doclets/internal/toolkit/util/Extern.java Wed Apr 23 18:04:02 2014 -0700 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -177,7 +177,7 @@ 1.11 try { 1.12 url = adjustEndFileSeparator(url); 1.13 if (isUrl(pkglisturl)) { 1.14 - readPackageListFromURL(url, toURL(pkglisturl)); 1.15 + readPackageListFromURL(url, toURL(adjustEndFileSeparator(pkglisturl))); 1.16 } else { 1.17 readPackageListFromFile(url, DocFile.createFileForInput(configuration, pkglisturl)); 1.18 }
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 23 11:35:48 2014 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 23 18:04:02 2014 -0700 2.3 @@ -249,7 +249,7 @@ 2.4 if (!owntype.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { 2.5 if (allowPoly && inferenceContext.free(found)) { 2.6 if ((ownkind & ~resultInfo.pkind) == 0) { 2.7 - owntype = resultInfo.check(tree, inferenceContext.asFree(owntype)); 2.8 + owntype = resultInfo.check(tree, inferenceContext.asUndetVar(owntype)); 2.9 } else { 2.10 log.error(tree.pos(), "unexpected.type", 2.11 kindNames(resultInfo.pkind), 2.12 @@ -2402,7 +2402,7 @@ 2.13 //add thrown types as bounds to the thrown types free variables if needed: 2.14 if (resultInfo.checkContext.inferenceContext().free(lambdaType.getThrownTypes())) { 2.15 List<Type> inferredThrownTypes = flow.analyzeLambdaThrownTypes(env, that, make); 2.16 - List<Type> thrownTypes = resultInfo.checkContext.inferenceContext().asFree(lambdaType.getThrownTypes()); 2.17 + List<Type> thrownTypes = resultInfo.checkContext.inferenceContext().asUndetVars(lambdaType.getThrownTypes()); 2.18 2.19 chk.unhandled(inferredThrownTypes, thrownTypes); 2.20 } 2.21 @@ -2543,7 +2543,7 @@ 2.22 @Override 2.23 public boolean compatible(Type found, Type req, Warner warn) { 2.24 //return type must be compatible in both current context and assignment context 2.25 - return chk.basicHandler.compatible(found, inferenceContext().asFree(req), warn); 2.26 + return chk.basicHandler.compatible(found, inferenceContext().asUndetVar(req), warn); 2.27 } 2.28 2.29 @Override 2.30 @@ -2576,7 +2576,7 @@ 2.31 * types must be compatible with the return type of the expected descriptor. 2.32 */ 2.33 private void checkLambdaCompatible(JCLambda tree, Type descriptor, CheckContext checkContext) { 2.34 - Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); 2.35 + Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType()); 2.36 2.37 //return values have already been checked - but if lambda has no return 2.38 //values, we must ensure that void/value compatibility is correct; 2.39 @@ -2588,7 +2588,7 @@ 2.40 diags.fragment("missing.ret.val", returnType))); 2.41 } 2.42 2.43 - List<Type> argTypes = checkContext.inferenceContext().asFree(descriptor.getParameterTypes()); 2.44 + List<Type> argTypes = checkContext.inferenceContext().asUndetVars(descriptor.getParameterTypes()); 2.45 if (!types.isSameTypes(argTypes, TreeInfo.types(tree.params))) { 2.46 checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); 2.47 } 2.48 @@ -2618,7 +2618,7 @@ 2.49 * - an instance field, we use the first constructor. 2.50 * - a static field, we create a fake clinit method. 2.51 */ 2.52 - private Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { 2.53 + public Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { 2.54 Env<AttrContext> lambdaEnv; 2.55 Symbol owner = env.info.scope.owner; 2.56 if (owner.kind == VAR && owner.owner.kind == TYP) { 2.57 @@ -2832,7 +2832,7 @@ 2.58 if (that.kind.isUnbound() && 2.59 resultInfo.checkContext.inferenceContext().free(argtypes.head)) { 2.60 //re-generate inference constraints for unbound receiver 2.61 - if (!types.isSubtype(resultInfo.checkContext.inferenceContext().asFree(argtypes.head), exprType)) { 2.62 + if (!types.isSubtype(resultInfo.checkContext.inferenceContext().asUndetVar(argtypes.head), exprType)) { 2.63 //cannot happen as this has already been checked - we just need 2.64 //to regenerate the inference constraints, as that has been lost 2.65 //as a result of the call to inferenceContext.save() 2.66 @@ -2870,7 +2870,7 @@ 2.67 2.68 @SuppressWarnings("fallthrough") 2.69 void checkReferenceCompatible(JCMemberReference tree, Type descriptor, Type refType, CheckContext checkContext, boolean speculativeAttr) { 2.70 - Type returnType = checkContext.inferenceContext().asFree(descriptor.getReturnType()); 2.71 + Type returnType = checkContext.inferenceContext().asUndetVar(descriptor.getReturnType()); 2.72 2.73 Type resType; 2.74 switch (tree.getMode()) { 2.75 @@ -2902,7 +2902,7 @@ 2.76 } 2.77 2.78 if (!speculativeAttr) { 2.79 - List<Type> thrownTypes = checkContext.inferenceContext().asFree(descriptor.getThrownTypes()); 2.80 + List<Type> thrownTypes = checkContext.inferenceContext().asUndetVars(descriptor.getThrownTypes()); 2.81 if (chk.unhandled(refType.getThrownTypes(), thrownTypes).nonEmpty()) { 2.82 log.error(tree, "incompatible.thrown.types.in.mref", refType.getThrownTypes()); 2.83 }
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Apr 23 11:35:48 2014 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Apr 23 18:04:02 2014 -0700 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -25,7 +25,7 @@ 3.11 3.12 package com.sun.tools.javac.comp; 3.13 3.14 -import com.sun.source.tree.MemberReferenceTree; 3.15 +import com.sun.source.tree.LambdaExpressionTree.BodyKind; 3.16 import com.sun.tools.javac.code.*; 3.17 import com.sun.tools.javac.tree.*; 3.18 import com.sun.tools.javac.util.*; 3.19 @@ -35,10 +35,8 @@ 3.20 import com.sun.tools.javac.comp.Attr.ResultInfo; 3.21 import com.sun.tools.javac.comp.Infer.InferenceContext; 3.22 import com.sun.tools.javac.comp.Resolve.MethodResolutionPhase; 3.23 -import com.sun.tools.javac.comp.Resolve.ReferenceLookupHelper; 3.24 import com.sun.tools.javac.tree.JCTree.*; 3.25 3.26 - 3.27 import java.util.ArrayList; 3.28 import java.util.Collections; 3.29 import java.util.EnumSet; 3.30 @@ -48,6 +46,7 @@ 3.31 import java.util.Set; 3.32 import java.util.WeakHashMap; 3.33 3.34 +import static com.sun.tools.javac.code.Kinds.VAL; 3.35 import static com.sun.tools.javac.code.TypeTag.*; 3.36 import static com.sun.tools.javac.tree.JCTree.Tag.*; 3.37 3.38 @@ -76,6 +75,8 @@ 3.39 final Symtab syms; 3.40 final TreeMaker make; 3.41 final Types types; 3.42 + final Flow flow; 3.43 + final Names names; 3.44 3.45 public static DeferredAttr instance(Context context) { 3.46 DeferredAttr instance = context.get(deferredAttrKey); 3.47 @@ -96,7 +97,8 @@ 3.48 syms = Symtab.instance(context); 3.49 make = TreeMaker.instance(context); 3.50 types = Types.instance(context); 3.51 - Names names = Names.instance(context); 3.52 + flow = Flow.instance(context); 3.53 + names = Names.instance(context); 3.54 stuckTree = make.Ident(names.empty).setType(Type.stuckType); 3.55 emptyDeferredAttrContext = 3.56 new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) { 3.57 @@ -139,6 +141,11 @@ 3.58 return DEFERRED; 3.59 } 3.60 3.61 + @Override 3.62 + public String toString() { 3.63 + return "DeferredType"; 3.64 + } 3.65 + 3.66 /** 3.67 * A speculative cache is used to keep track of all overload resolution rounds 3.68 * that triggered speculative attribution on a given deferred type. Each entry 3.69 @@ -378,7 +385,9 @@ 3.70 } 3.71 } 3.72 //where 3.73 - protected TreeScanner unenterScanner = new TreeScanner() { 3.74 + protected UnenterScanner unenterScanner = new UnenterScanner(); 3.75 + 3.76 + class UnenterScanner extends TreeScanner { 3.77 @Override 3.78 public void visitClassDef(JCClassDecl tree) { 3.79 ClassSymbol csym = tree.sym; 3.80 @@ -391,7 +400,7 @@ 3.81 syms.classes.remove(csym.flatname); 3.82 super.visitClassDef(tree); 3.83 } 3.84 - }; 3.85 + } 3.86 3.87 /** 3.88 * A deferred context is created on each method check. A deferred context is 3.89 @@ -595,19 +604,111 @@ 3.90 public void visitLambda(JCLambda tree) { 3.91 Check.CheckContext checkContext = resultInfo.checkContext; 3.92 Type pt = resultInfo.pt; 3.93 - if (inferenceContext.inferencevars.contains(pt)) { 3.94 - //ok 3.95 - return; 3.96 - } else { 3.97 + if (!inferenceContext.inferencevars.contains(pt)) { 3.98 //must be a functional descriptor 3.99 + Type descriptorType = null; 3.100 try { 3.101 - Type desc = types.findDescriptorType(pt); 3.102 - if (desc.getParameterTypes().length() != tree.params.length()) { 3.103 - checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); 3.104 - } 3.105 + descriptorType = types.findDescriptorType(pt); 3.106 } catch (Types.FunctionDescriptorLookupError ex) { 3.107 checkContext.report(null, ex.getDiagnostic()); 3.108 } 3.109 + 3.110 + if (descriptorType.getParameterTypes().length() != tree.params.length()) { 3.111 + checkContext.report(tree, 3.112 + diags.fragment("incompatible.arg.types.in.lambda")); 3.113 + } 3.114 + 3.115 + Type currentReturnType = descriptorType.getReturnType(); 3.116 + boolean returnTypeIsVoid = currentReturnType.hasTag(VOID); 3.117 + if (tree.getBodyKind() == BodyKind.EXPRESSION) { 3.118 + boolean isExpressionCompatible = !returnTypeIsVoid || 3.119 + TreeInfo.isExpressionStatement((JCExpression)tree.getBody()); 3.120 + if (!isExpressionCompatible) { 3.121 + resultInfo.checkContext.report(tree.pos(), 3.122 + diags.fragment("incompatible.ret.type.in.lambda", 3.123 + diags.fragment("missing.ret.val", currentReturnType))); 3.124 + } 3.125 + } else { 3.126 + LambdaBodyStructChecker lambdaBodyChecker = 3.127 + new LambdaBodyStructChecker(); 3.128 + 3.129 + tree.body.accept(lambdaBodyChecker); 3.130 + boolean isVoidCompatible = lambdaBodyChecker.isVoidCompatible; 3.131 + 3.132 + if (returnTypeIsVoid) { 3.133 + if (!isVoidCompatible) { 3.134 + resultInfo.checkContext.report(tree.pos(), 3.135 + diags.fragment("unexpected.ret.val")); 3.136 + } 3.137 + } else { 3.138 + boolean isValueCompatible = lambdaBodyChecker.isPotentiallyValueCompatible 3.139 + && !canLambdaBodyCompleteNormally(tree); 3.140 + if (!isValueCompatible && !isVoidCompatible) { 3.141 + log.error(tree.body.pos(), 3.142 + "lambda.body.neither.value.nor.void.compatible"); 3.143 + } 3.144 + 3.145 + if (!isValueCompatible) { 3.146 + resultInfo.checkContext.report(tree.pos(), 3.147 + diags.fragment("incompatible.ret.type.in.lambda", 3.148 + diags.fragment("missing.ret.val", currentReturnType))); 3.149 + } 3.150 + } 3.151 + } 3.152 + } 3.153 + } 3.154 + 3.155 + boolean canLambdaBodyCompleteNormally(JCLambda tree) { 3.156 + JCLambda newTree = new TreeCopier<>(make).copy(tree); 3.157 + /* attr.lambdaEnv will create a meaningful env for the 3.158 + * lambda expression. This is specially useful when the 3.159 + * lambda is used as the init of a field. But we need to 3.160 + * remove any added symbol. 3.161 + */ 3.162 + Env<AttrContext> localEnv = attr.lambdaEnv(newTree, env); 3.163 + try { 3.164 + List<JCVariableDecl> tmpParams = newTree.params; 3.165 + while (tmpParams.nonEmpty()) { 3.166 + tmpParams.head.vartype = make.at(tmpParams.head).Type(syms.errType); 3.167 + tmpParams = tmpParams.tail; 3.168 + } 3.169 + 3.170 + attr.attribStats(newTree.params, localEnv); 3.171 + 3.172 + /* set pt to Type.noType to avoid generating any bound 3.173 + * which may happen if lambda's return type is an 3.174 + * inference variable 3.175 + */ 3.176 + Attr.ResultInfo bodyResultInfo = attr.new ResultInfo(VAL, Type.noType); 3.177 + localEnv.info.returnResult = bodyResultInfo; 3.178 + 3.179 + // discard any log output 3.180 + Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); 3.181 + try { 3.182 + JCBlock body = (JCBlock)newTree.body; 3.183 + /* we need to attribute the lambda body before 3.184 + * doing the aliveness analysis. This is because 3.185 + * constant folding occurs during attribution 3.186 + * and the reachability of some statements depends 3.187 + * on constant values, for example: 3.188 + * 3.189 + * while (true) {...} 3.190 + */ 3.191 + attr.attribStats(body.stats, localEnv); 3.192 + 3.193 + attr.preFlow(newTree); 3.194 + /* make an aliveness / reachability analysis of the lambda 3.195 + * to determine if it can complete normally 3.196 + */ 3.197 + flow.analyzeLambda(localEnv, newTree, make, true); 3.198 + } finally { 3.199 + log.popDiagnosticHandler(diagHandler); 3.200 + } 3.201 + return newTree.canCompleteNormally; 3.202 + } finally { 3.203 + JCBlock body = (JCBlock)newTree.body; 3.204 + unenterScanner.scan(body.stats); 3.205 + localEnv.info.scope.leave(); 3.206 } 3.207 } 3.208 3.209 @@ -625,10 +726,7 @@ 3.210 public void visitReference(JCMemberReference tree) { 3.211 Check.CheckContext checkContext = resultInfo.checkContext; 3.212 Type pt = resultInfo.pt; 3.213 - if (inferenceContext.inferencevars.contains(pt)) { 3.214 - //ok 3.215 - return; 3.216 - } else { 3.217 + if (!inferenceContext.inferencevars.contains(pt)) { 3.218 try { 3.219 types.findDescriptorType(pt); 3.220 } catch (Types.FunctionDescriptorLookupError ex) { 3.221 @@ -658,6 +756,40 @@ 3.222 } 3.223 } 3.224 } 3.225 + 3.226 + /* This visitor looks for return statements, its analysis will determine if 3.227 + * a lambda body is void or value compatible. We must analyze return 3.228 + * statements contained in the lambda body only, thus any return statement 3.229 + * contained in an inner class or inner lambda body, should be ignored. 3.230 + */ 3.231 + class LambdaBodyStructChecker extends TreeScanner { 3.232 + boolean isVoidCompatible = true; 3.233 + boolean isPotentiallyValueCompatible = true; 3.234 + 3.235 + @Override 3.236 + public void visitClassDef(JCClassDecl tree) { 3.237 + // do nothing 3.238 + } 3.239 + 3.240 + @Override 3.241 + public void visitLambda(JCLambda tree) { 3.242 + // do nothing 3.243 + } 3.244 + 3.245 + @Override 3.246 + public void visitNewClass(JCNewClass tree) { 3.247 + // do nothing 3.248 + } 3.249 + 3.250 + @Override 3.251 + public void visitReturn(JCReturn tree) { 3.252 + if (tree.expr != null) { 3.253 + isVoidCompatible = false; 3.254 + } else { 3.255 + isPotentiallyValueCompatible = false; 3.256 + } 3.257 + } 3.258 + } 3.259 } 3.260 3.261 /** an empty deferred attribution context - all methods throw exceptions */ 3.262 @@ -769,7 +901,7 @@ 3.263 /** 3.264 * handler that is executed when a node has been discarded 3.265 */ 3.266 - abstract void skip(JCTree tree); 3.267 + void skip(JCTree tree) {} 3.268 } 3.269 3.270 /** 3.271 @@ -781,11 +913,6 @@ 3.272 PolyScanner() { 3.273 super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE)); 3.274 } 3.275 - 3.276 - @Override 3.277 - void skip(JCTree tree) { 3.278 - //do nothing 3.279 - } 3.280 } 3.281 3.282 /** 3.283 @@ -798,11 +925,6 @@ 3.284 super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, 3.285 FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); 3.286 } 3.287 - 3.288 - @Override 3.289 - void skip(JCTree tree) { 3.290 - //do nothing 3.291 - } 3.292 } 3.293 3.294 /**
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Wed Apr 23 11:35:48 2014 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Wed Apr 23 18:04:02 2014 -0700 4.3 @@ -45,7 +45,7 @@ 4.4 import static com.sun.tools.javac.tree.JCTree.Tag.*; 4.5 4.6 /** This pass implements dataflow analysis for Java programs though 4.7 - * different AST visitor steps. Liveness analysis (see AliveAlanyzer) checks that 4.8 + * different AST visitor steps. Liveness analysis (see AliveAnalyzer) checks that 4.9 * every statement is reachable. Exception analysis (see FlowAnalyzer) ensures that 4.10 * every checked exception that is thrown is declared or caught. Definite assignment analysis 4.11 * (see AssignAnalyzer) ensures that each variable is assigned when used. Definite
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Apr 23 11:35:48 2014 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Wed Apr 23 18:04:02 2014 -0700 5.3 @@ -220,9 +220,10 @@ 5.4 */ 5.5 Type generateReturnConstraints(Attr.ResultInfo resultInfo, 5.6 MethodType mt, InferenceContext inferenceContext) { 5.7 + InferenceContext rsInfoInfContext = resultInfo.checkContext.inferenceContext(); 5.8 Type from = mt.getReturnType(); 5.9 if (mt.getReturnType().containsAny(inferenceContext.inferencevars) && 5.10 - resultInfo.checkContext.inferenceContext() != emptyContext) { 5.11 + rsInfoInfContext != emptyContext) { 5.12 from = types.capture(from); 5.13 //add synthetic captured ivars 5.14 for (Type t : from.getTypeArguments()) { 5.15 @@ -231,13 +232,13 @@ 5.16 } 5.17 } 5.18 } 5.19 - Type qtype1 = inferenceContext.asFree(from); 5.20 + Type qtype1 = inferenceContext.asUndetVar(from); 5.21 Type to = returnConstraintTarget(qtype1, resultInfo.pt); 5.22 - Assert.check(allowGraphInference || !resultInfo.checkContext.inferenceContext().free(to), 5.23 + Assert.check(allowGraphInference || !rsInfoInfContext.free(to), 5.24 "legacy inference engine cannot handle constraints on both sides of a subtyping assertion"); 5.25 //we need to skip capture? 5.26 Warner retWarn = new Warner(); 5.27 - if (!resultInfo.checkContext.compatible(qtype1, resultInfo.checkContext.inferenceContext().asFree(to), retWarn) || 5.28 + if (!resultInfo.checkContext.compatible(qtype1, rsInfoInfContext.asUndetVar(to), retWarn) || 5.29 //unchecked conversion is not allowed in source 7 mode 5.30 (!allowGraphInference && retWarn.hasLint(Lint.LintCategory.UNCHECKED))) { 5.31 throw inferenceException 5.32 @@ -280,7 +281,7 @@ 5.33 ListBuffer<Type> todo = new ListBuffer<>(); 5.34 //step 1 - create fresh tvars 5.35 for (Type t : vars) { 5.36 - UndetVar uv = (UndetVar)inferenceContext.asFree(t); 5.37 + UndetVar uv = (UndetVar)inferenceContext.asUndetVar(t); 5.38 List<Type> upperBounds = uv.getBounds(InferenceBound.UPPER); 5.39 if (Type.containsAny(upperBounds, vars)) { 5.40 TypeSymbol fresh_tvar = new TypeVariableSymbol(Flags.SYNTHETIC, uv.qtype.tsym.name, null, uv.qtype.tsym.owner); 5.41 @@ -399,7 +400,7 @@ 5.42 return types.createErrorType(funcInterface); 5.43 } 5.44 for (Type p : descParameterTypes) { 5.45 - if (!types.isSameType(funcInterfaceContext.asFree(p), paramTypes.head)) { 5.46 + if (!types.isSameType(funcInterfaceContext.asUndetVar(p), paramTypes.head)) { 5.47 checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface)); 5.48 return types.createErrorType(funcInterface); 5.49 } 5.50 @@ -515,6 +516,32 @@ 5.51 /** max number of incorporation rounds */ 5.52 static final int MAX_INCORPORATION_STEPS = 100; 5.53 5.54 + /* If for two types t and s there is a least upper bound that is a 5.55 + * parameterized type G, then there exists a supertype of 't' of the form 5.56 + * G<T1, ..., Tn> and a supertype of 's' of the form G<S1, ..., Sn> 5.57 + * which will be returned by this method. If no such supertypes exists then 5.58 + * null is returned. 5.59 + * 5.60 + * As an example for the following input: 5.61 + * 5.62 + * t = java.util.ArrayList<java.lang.String> 5.63 + * s = java.util.List<T> 5.64 + * 5.65 + * we get this ouput: 5.66 + * 5.67 + * Pair[java.util.List<java.lang.String>,java.util.List<T>] 5.68 + */ 5.69 + private Pair<Type, Type> getParameterizedSupers(Type t, Type s) { 5.70 + Type lubResult = types.lub(t, s); 5.71 + if (lubResult == syms.errType || lubResult == syms.botType || 5.72 + !lubResult.isParameterized()) { 5.73 + return null; 5.74 + } 5.75 + Type asSuperOfT = types.asSuper(t, lubResult.tsym); 5.76 + Type asSuperOfS = types.asSuper(s, lubResult.tsym); 5.77 + return new Pair<>(asSuperOfT, asSuperOfS); 5.78 + } 5.79 + 5.80 /** 5.81 * This enumeration defines an entry point for doing inference variable 5.82 * bound incorporation - it can be used to inject custom incorporation 5.83 @@ -533,22 +560,23 @@ 5.84 if (uv.inst != null) { 5.85 Type inst = uv.inst; 5.86 for (Type u : uv.getBounds(InferenceBound.UPPER)) { 5.87 - if (!isSubtype(inst, inferenceContext.asFree(u), warn, infer)) { 5.88 + if (!isSubtype(inst, inferenceContext.asUndetVar(u), warn, infer)) { 5.89 infer.reportBoundError(uv, BoundErrorKind.UPPER); 5.90 } 5.91 } 5.92 for (Type l : uv.getBounds(InferenceBound.LOWER)) { 5.93 - if (!isSubtype(inferenceContext.asFree(l), inst, warn, infer)) { 5.94 + if (!isSubtype(inferenceContext.asUndetVar(l), inst, warn, infer)) { 5.95 infer.reportBoundError(uv, BoundErrorKind.LOWER); 5.96 } 5.97 } 5.98 for (Type e : uv.getBounds(InferenceBound.EQ)) { 5.99 - if (!isSameType(inst, inferenceContext.asFree(e), infer)) { 5.100 + if (!isSameType(inst, inferenceContext.asUndetVar(e), infer)) { 5.101 infer.reportBoundError(uv, BoundErrorKind.EQ); 5.102 } 5.103 } 5.104 } 5.105 } 5.106 + 5.107 @Override 5.108 boolean accepts(UndetVar uv, InferenceContext inferenceContext) { 5.109 //applies to all undetvars 5.110 @@ -594,12 +622,12 @@ 5.111 for (Type e : uv.getBounds(InferenceBound.EQ)) { 5.112 if (e.containsAny(inferenceContext.inferenceVars())) continue; 5.113 for (Type u : uv.getBounds(InferenceBound.UPPER)) { 5.114 - if (!isSubtype(e, inferenceContext.asFree(u), warn, infer)) { 5.115 + if (!isSubtype(e, inferenceContext.asUndetVar(u), warn, infer)) { 5.116 infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_UPPER); 5.117 } 5.118 } 5.119 for (Type l : uv.getBounds(InferenceBound.LOWER)) { 5.120 - if (!isSubtype(inferenceContext.asFree(l), e, warn, infer)) { 5.121 + if (!isSubtype(inferenceContext.asUndetVar(l), e, warn, infer)) { 5.122 infer.reportBoundError(uv, BoundErrorKind.BAD_EQ_LOWER); 5.123 } 5.124 } 5.125 @@ -615,7 +643,7 @@ 5.126 Infer infer = inferenceContext.infer(); 5.127 for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { 5.128 for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { 5.129 - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn , infer); 5.130 + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn , infer); 5.131 } 5.132 } 5.133 } 5.134 @@ -629,7 +657,7 @@ 5.135 Infer infer = inferenceContext.infer(); 5.136 for (Type b1 : uv.getBounds(InferenceBound.UPPER)) { 5.137 for (Type b2 : uv.getBounds(InferenceBound.EQ)) { 5.138 - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer); 5.139 + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn, infer); 5.140 } 5.141 } 5.142 } 5.143 @@ -643,12 +671,59 @@ 5.144 Infer infer = inferenceContext.infer(); 5.145 for (Type b1 : uv.getBounds(InferenceBound.EQ)) { 5.146 for (Type b2 : uv.getBounds(InferenceBound.LOWER)) { 5.147 - isSubtype(inferenceContext.asFree(b2), inferenceContext.asFree(b1), warn, infer); 5.148 + isSubtype(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), warn, infer); 5.149 } 5.150 } 5.151 } 5.152 }, 5.153 /** 5.154 + * Given a bound set containing {@code alpha <: P<T>} and 5.155 + * {@code alpha <: P<S>} where P is a parameterized type, 5.156 + * perform {@code T = S} (which could lead to new bounds). 5.157 + */ 5.158 + CROSS_UPPER_UPPER() { 5.159 + @Override 5.160 + public void apply(UndetVar uv, InferenceContext inferenceContext, Warner warn) { 5.161 + Infer infer = inferenceContext.infer(); 5.162 + List<Type> boundList = uv.getBounds(InferenceBound.UPPER); 5.163 + List<Type> boundListTail = boundList.tail; 5.164 + while (boundList.nonEmpty()) { 5.165 + List<Type> tmpTail = boundListTail; 5.166 + while (tmpTail.nonEmpty()) { 5.167 + Type b1 = boundList.head; 5.168 + Type b2 = tmpTail.head; 5.169 + if (b1 != b2) { 5.170 + Pair<Type, Type> commonSupers = infer.getParameterizedSupers(b1, b2); 5.171 + if (commonSupers != null) { 5.172 + List<Type> allParamsSuperBound1 = commonSupers.fst.allparams(); 5.173 + List<Type> allParamsSuperBound2 = commonSupers.snd.allparams(); 5.174 + while (allParamsSuperBound1.nonEmpty() && allParamsSuperBound2.nonEmpty()) { 5.175 + //traverse the list of all params comparing them 5.176 + if (!allParamsSuperBound1.head.hasTag(WILDCARD) && 5.177 + !allParamsSuperBound2.head.hasTag(WILDCARD)) { 5.178 + isSameType(inferenceContext.asUndetVar(allParamsSuperBound1.head), 5.179 + inferenceContext.asUndetVar(allParamsSuperBound2.head), infer); 5.180 + } 5.181 + allParamsSuperBound1 = allParamsSuperBound1.tail; 5.182 + allParamsSuperBound2 = allParamsSuperBound2.tail; 5.183 + } 5.184 + Assert.check(allParamsSuperBound1.isEmpty() && allParamsSuperBound2.isEmpty()); 5.185 + } 5.186 + } 5.187 + tmpTail = tmpTail.tail; 5.188 + } 5.189 + boundList = boundList.tail; 5.190 + boundListTail = boundList.tail; 5.191 + } 5.192 + } 5.193 + 5.194 + @Override 5.195 + boolean accepts(UndetVar uv, InferenceContext inferenceContext) { 5.196 + return !uv.isCaptured() && 5.197 + uv.getBounds(InferenceBound.UPPER).nonEmpty(); 5.198 + } 5.199 + }, 5.200 + /** 5.201 * Given a bound set containing {@code alpha == S} and {@code alpha == T} 5.202 * perform {@code S == T} (which could lead to new bounds). 5.203 */ 5.204 @@ -658,7 +733,7 @@ 5.205 for (Type b1 : uv.getBounds(InferenceBound.EQ)) { 5.206 for (Type b2 : uv.getBounds(InferenceBound.EQ)) { 5.207 if (b1 != b2) { 5.208 - isSameType(inferenceContext.asFree(b2), inferenceContext.asFree(b1), infer); 5.209 + isSameType(inferenceContext.asUndetVar(b2), inferenceContext.asUndetVar(b1), infer); 5.210 } 5.211 } 5.212 } 5.213 @@ -673,7 +748,7 @@ 5.214 Infer infer = inferenceContext.infer(); 5.215 for (Type b : uv.getBounds(InferenceBound.UPPER)) { 5.216 if (inferenceContext.inferenceVars().contains(b)) { 5.217 - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); 5.218 + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); 5.219 if (uv2.isCaptured()) continue; 5.220 //alpha <: beta 5.221 //0. set beta :> alpha 5.222 @@ -699,7 +774,7 @@ 5.223 Infer infer = inferenceContext.infer(); 5.224 for (Type b : uv.getBounds(InferenceBound.LOWER)) { 5.225 if (inferenceContext.inferenceVars().contains(b)) { 5.226 - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); 5.227 + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); 5.228 if (uv2.isCaptured()) continue; 5.229 //alpha :> beta 5.230 //0. set beta <: alpha 5.231 @@ -725,7 +800,7 @@ 5.232 Infer infer = inferenceContext.infer(); 5.233 for (Type b : uv.getBounds(InferenceBound.EQ)) { 5.234 if (inferenceContext.inferenceVars().contains(b)) { 5.235 - UndetVar uv2 = (UndetVar)inferenceContext.asFree(b); 5.236 + UndetVar uv2 = (UndetVar)inferenceContext.asUndetVar(b); 5.237 if (uv2.isCaptured()) continue; 5.238 //alpha == beta 5.239 //0. set beta == alpha 5.240 @@ -1475,7 +1550,7 @@ 5.241 StringBuilder buf = new StringBuilder(); 5.242 String sep = ""; 5.243 for (Type from : data) { 5.244 - UndetVar uv = (UndetVar)inferenceContext.asFree(from); 5.245 + UndetVar uv = (UndetVar)inferenceContext.asUndetVar(from); 5.246 for (Type bound : uv.getBounds(InferenceBound.values())) { 5.247 if (bound.containsAny(List.from(to.data))) { 5.248 buf.append(sep); 5.249 @@ -1684,7 +1759,7 @@ 5.250 Set<Type> optDepsByNode = stuckDeps.get(i); 5.251 for (Node n_j : nodes) { 5.252 Type j = n_j.data.first(); 5.253 - UndetVar uv_i = (UndetVar)inferenceContext.asFree(i); 5.254 + UndetVar uv_i = (UndetVar)inferenceContext.asUndetVar(i); 5.255 if (Type.containsAny(uv_i.getBounds(InferenceBound.values()), List.of(j))) { 5.256 //update i's bound dependencies 5.257 n_i.addDependency(DependencyKind.BOUND, n_j); 5.258 @@ -1833,6 +1908,8 @@ 5.259 }); 5.260 } 5.261 5.262 + /* Returns the corresponding inference variables. 5.263 + */ 5.264 private List<Type> filterVars(Filter<UndetVar> fu) { 5.265 ListBuffer<Type> res = new ListBuffer<>(); 5.266 for (Type t : undetvars) { 5.267 @@ -1890,14 +1967,14 @@ 5.268 * undet vars (used ahead of subtyping/compatibility checks to allow propagation 5.269 * of inference constraints). 5.270 */ 5.271 - final Type asFree(Type t) { 5.272 + final Type asUndetVar(Type t) { 5.273 return types.subst(t, inferencevars, undetvars); 5.274 } 5.275 5.276 - final List<Type> asFree(List<Type> ts) { 5.277 + final List<Type> asUndetVars(List<Type> ts) { 5.278 ListBuffer<Type> buf = new ListBuffer<>(); 5.279 for (Type t : ts) { 5.280 - buf.append(asFree(t)); 5.281 + buf.append(asUndetVar(t)); 5.282 } 5.283 return buf.toList(); 5.284 } 5.285 @@ -2073,7 +2150,7 @@ 5.286 private boolean solveBasic(List<Type> varsToSolve, EnumSet<InferenceStep> steps) { 5.287 boolean changed = false; 5.288 for (Type t : varsToSolve.intersect(restvars())) { 5.289 - UndetVar uv = (UndetVar)asFree(t); 5.290 + UndetVar uv = (UndetVar)asUndetVar(t); 5.291 for (InferenceStep step : steps) { 5.292 if (step.accepts(uv, this)) { 5.293 uv.inst = step.solve(uv, this);
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Apr 23 11:35:48 2014 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Wed Apr 23 18:04:02 2014 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 6.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.8 * 6.9 * This code is free software; you can redistribute it and/or modify it 6.10 @@ -2360,6 +2360,7 @@ 6.11 /** Visitor method: Translate a single node. 6.12 * Attach the source position from the old tree to its replacement tree. 6.13 */ 6.14 + @Override 6.15 public <T extends JCTree> T translate(T tree) { 6.16 if (tree == null) { 6.17 return null;
7.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Apr 23 11:35:48 2014 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Apr 23 18:04:02 2014 -0700 7.3 @@ -899,7 +899,7 @@ 7.4 7.5 @Override 7.6 public boolean compatible(Type found, Type req, Warner warn) { 7.7 - found = pendingInferenceContext.asFree(found); 7.8 + found = pendingInferenceContext.asUndetVar(found); 7.9 req = infer.returnConstraintTarget(found, req); 7.10 return super.compatible(found, req, warn); 7.11 } 7.12 @@ -936,8 +936,8 @@ 7.13 7.14 public boolean compatible(Type found, Type req, Warner warn) { 7.15 return strict ? 7.16 - types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asFree(req), warn) : 7.17 - types.isConvertible(found, deferredAttrContext.inferenceContext.asFree(req), warn); 7.18 + types.isSubtypeUnchecked(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn) : 7.19 + types.isConvertible(found, deferredAttrContext.inferenceContext.asUndetVar(req), warn); 7.20 } 7.21 7.22 public void report(DiagnosticPosition pos, JCDiagnostic details) { 7.23 @@ -1142,7 +1142,7 @@ 7.24 Type desc_t = types.findDescriptorType(t); 7.25 Type desc_s = types.findDescriptorType(s); 7.26 if (types.isSameTypes(desc_t.getParameterTypes(), 7.27 - inferenceContext().asFree(desc_s.getParameterTypes()))) { 7.28 + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { 7.29 if (types.asSuper(t, s.tsym) != null || 7.30 types.asSuper(s, t.tsym) != null) { 7.31 result &= MostSpecificCheckContext.super.compatible(t, s, warn); 7.32 @@ -1169,7 +1169,7 @@ 7.33 Type desc_t = types.findDescriptorType(t); 7.34 Type desc_s = types.findDescriptorType(s); 7.35 if (types.isSameTypes(desc_t.getParameterTypes(), 7.36 - inferenceContext().asFree(desc_s.getParameterTypes()))) { 7.37 + inferenceContext().asUndetVars(desc_s.getParameterTypes()))) { 7.38 if (types.asSuper(t, s.tsym) != null || 7.39 types.asSuper(s, t.tsym) != null) { 7.40 result &= MostSpecificCheckContext.super.compatible(t, s, warn); 7.41 @@ -3152,7 +3152,7 @@ 7.42 if (TreeInfo.isStaticSelector(referenceTree.expr, names) && 7.43 argtypes.nonEmpty() && 7.44 (argtypes.head.hasTag(NONE) || 7.45 - types.isSubtypeUnchecked(inferenceContext.asFree(argtypes.head), site))) { 7.46 + types.isSubtypeUnchecked(inferenceContext.asUndetVar(argtypes.head), site))) { 7.47 return new UnboundMethodReferenceLookupHelper(referenceTree, name, 7.48 site, argtypes, typeargtypes, maxPhase); 7.49 } else { 7.50 @@ -4265,7 +4265,11 @@ 7.51 } 7.52 7.53 DeferredAttrContext deferredAttrContext(Symbol sym, InferenceContext inferenceContext, ResultInfo pendingResult, Warner warn) { 7.54 - return deferredAttr.new DeferredAttrContext(attrMode, sym, step, inferenceContext, pendingResult != null ? pendingResult.checkContext.deferredAttrContext() : deferredAttr.emptyDeferredAttrContext, warn); 7.55 + DeferredAttrContext parent = (pendingResult == null) 7.56 + ? deferredAttr.emptyDeferredAttrContext 7.57 + : pendingResult.checkContext.deferredAttrContext(); 7.58 + return deferredAttr.new DeferredAttrContext(attrMode, sym, step, 7.59 + inferenceContext, parent, warn); 7.60 } 7.61 7.62 /**
8.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 23 11:35:48 2014 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 23 18:04:02 2014 -0700 8.3 @@ -1,5 +1,5 @@ 8.4 # 8.5 -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 8.6 +# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 8.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.8 # 8.9 # This code is free software; you can redistribute it and/or modify it 8.10 @@ -735,6 +735,9 @@ 8.11 bad return type in method reference\n\ 8.12 {0} 8.13 8.14 +compiler.err.lambda.body.neither.value.nor.void.compatible=\ 8.15 + lambda body is neither value nor void compatible 8.16 + 8.17 # 0: list of type 8.18 compiler.err.incompatible.thrown.types.in.mref=\ 8.19 incompatible thrown types {0} in method reference
9.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Wed Apr 23 11:35:48 2014 -0700 9.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Wed Apr 23 18:04:02 2014 -0700 9.3 @@ -1,5 +1,5 @@ 9.4 /* 9.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 9.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 9.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 9.8 * 9.9 * This code is free software; you can redistribute it and/or modify it 9.10 @@ -56,9 +56,9 @@ 9.11 return null; 9.12 } else { 9.13 tree.accept(this); 9.14 - JCTree result = this.result; 9.15 + JCTree tmpResult = this.result; 9.16 this.result = null; 9.17 - return (T)result; // XXX cast 9.18 + return (T)tmpResult; // XXX cast 9.19 } 9.20 } 9.21
10.1 --- a/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Wed Apr 23 11:35:48 2014 -0700 10.2 +++ b/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Wed Apr 23 18:04:02 2014 -0700 10.3 @@ -68,6 +68,7 @@ 10.4 final Messager messager; 10.5 final JavadocClassReader javadocReader; 10.6 final JavadocEnter javadocEnter; 10.7 + final Set<JavaFileObject> uniquefiles; 10.8 10.9 /** 10.10 * Construct a new JavaCompiler processor, using appropriately 10.11 @@ -78,6 +79,7 @@ 10.12 messager = Messager.instance0(context); 10.13 javadocReader = JavadocClassReader.instance0(context); 10.14 javadocEnter = JavadocEnter.instance0(context); 10.15 + uniquefiles = new HashSet<>(); 10.16 } 10.17 10.18 /** 10.19 @@ -148,9 +150,7 @@ 10.20 String name = it.head; 10.21 if (!docClasses && fm != null && name.endsWith(".java") && new File(name).exists()) { 10.22 JavaFileObject fo = fm.getJavaFileObjects(name).iterator().next(); 10.23 - docenv.notice("main.Loading_source_file", name); 10.24 - JCCompilationUnit tree = parse(fo); 10.25 - classTrees.append(tree); 10.26 + parse(fo, classTrees, true); 10.27 } else if (isValidPackageName(name)) { 10.28 names = names.append(name); 10.29 } else if (name.endsWith(".java")) { 10.30 @@ -163,9 +163,7 @@ 10.31 } 10.32 } 10.33 for (JavaFileObject fo: fileObjects) { 10.34 - docenv.notice("main.Loading_source_file", fo.getName()); 10.35 - JCCompilationUnit tree = parse(fo); 10.36 - classTrees.append(tree); 10.37 + parse(fo, classTrees, true); 10.38 } 10.39 10.40 if (!docClasses) { 10.41 @@ -213,7 +211,7 @@ 10.42 * .java files found in such a directory to args. 10.43 */ 10.44 private void parsePackageClasses(String name, 10.45 - Iterable<JavaFileObject> files, 10.46 + List<JavaFileObject> files, 10.47 ListBuffer<JCCompilationUnit> trees, 10.48 List<String> excludedPackages) 10.49 throws IOException { 10.50 @@ -221,7 +219,6 @@ 10.51 return; 10.52 } 10.53 10.54 - boolean hasFiles = false; 10.55 docenv.notice("main.Loading_source_files_for_package", name); 10.56 10.57 if (files == null) { 10.58 @@ -238,19 +235,22 @@ 10.59 } 10.60 files = lb.toList(); 10.61 } 10.62 + if (files.nonEmpty()) { 10.63 + for (JavaFileObject fo : files) { 10.64 + parse(fo, trees, false); 10.65 + } 10.66 + } else { 10.67 + messager.warning(Messager.NOPOS, "main.no_source_files_for_package", 10.68 + name.replace(File.separatorChar, '.')); 10.69 + } 10.70 + } 10.71 10.72 - Set<JavaFileObject> ufiles = new HashSet<>(); 10.73 - for (JavaFileObject fo : files) { 10.74 - if (ufiles.add(fo)) { // ignore duplicates 10.75 - // messager.notice("main.Loading_source_file", fn); 10.76 - trees.append(parse(fo)); 10.77 - hasFiles = true; 10.78 - } 10.79 - } 10.80 - 10.81 - if (!hasFiles) { 10.82 - messager.warning(Messager.NOPOS, "main.no_source_files_for_package", 10.83 - name.replace(File.separatorChar, '.')); 10.84 + private void parse(JavaFileObject fo, ListBuffer<JCCompilationUnit> trees, 10.85 + boolean trace) { 10.86 + if (uniquefiles.add(fo)) { // ignore duplicates 10.87 + if (trace) 10.88 + docenv.notice("main.Loading_source_file", fo.getName()); 10.89 + trees.append(parse(fo)); 10.90 } 10.91 } 10.92
11.1 --- a/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Wed Apr 23 11:35:48 2014 -0700 11.2 +++ b/test/com/sun/javadoc/testLinkOption/TestLinkOption.java Wed Apr 23 18:04:02 2014 -0700 11.3 @@ -23,18 +23,20 @@ 11.4 11.5 /* 11.6 * @test 11.7 - * @bug 4720957 5020118 8026567 11.8 + * @bug 4720957 5020118 8026567 8038976 11.9 * @summary Test to make sure that -link and -linkoffline link to 11.10 - * right files. 11.11 + * right files, and URLs with and without trailing slash are accepted. 11.12 * @author jamieh 11.13 * @library ../lib/ 11.14 * @build JavadocTester TestLinkOption 11.15 * @run main TestLinkOption 11.16 */ 11.17 11.18 +import java.io.File; 11.19 + 11.20 public class TestLinkOption extends JavadocTester { 11.21 11.22 - private static final String BUG_ID = "4720957-5020118"; 11.23 + private static final String BUG_ID = "4720957-5020118-8038976"; 11.24 11.25 //Generate the documentation using -linkoffline and a URL as the first parameter. 11.26 private static final String[] ARGS1 = new String[] { 11.27 @@ -83,7 +85,34 @@ 11.28 } 11.29 }; 11.30 private static final String[][] NEGATED_TEST2 = NO_TEST; 11.31 - 11.32 + /* 11.33 + * Create the documentation using the -link option, vary the behavior with 11.34 + * both trailing and no trailing slash. We are only interested in ensuring 11.35 + * that the command executes with no errors or related warnings. 11.36 + */ 11.37 + static String[] createArguments(boolean withTrailingSlash) { 11.38 + String packagePath = new File(BUG_ID + "-1").getAbsolutePath(); 11.39 + String outputDirName = BUG_ID; 11.40 + if (withTrailingSlash) { 11.41 + // add the trailing slash, if it is not present! 11.42 + if (!packagePath.endsWith(FS)) { 11.43 + packagePath = packagePath + FS; 11.44 + } 11.45 + outputDirName = outputDirName + "-3"; 11.46 + } else { 11.47 + // remove the trailing slash, if it is present! 11.48 + if (packagePath.endsWith(FS)) { 11.49 + packagePath = packagePath.substring(0, packagePath.length() - 1); 11.50 + } 11.51 + outputDirName = outputDirName + "-4"; 11.52 + } 11.53 + String args[] = { 11.54 + "-d", outputDirName, "-sourcepath", SRC_DIR, 11.55 + "-link", "file:///" + packagePath, "-package", "pkg2" 11.56 + }; 11.57 + System.out.println("packagePath: " + packagePath); 11.58 + return args; 11.59 + } 11.60 /** 11.61 * The entry point of the test. 11.62 * @param args the array of command line arguments. 11.63 @@ -92,6 +121,12 @@ 11.64 TestLinkOption tester = new TestLinkOption(); 11.65 run(tester, ARGS1, TEST1, NEGATED_TEST1); 11.66 run(tester, ARGS2, TEST2, NEGATED_TEST2); 11.67 + tester.runJavadoc(createArguments(true)); // with trailing slash 11.68 + tester.runJavadoc(createArguments(false)); // without trailing slash 11.69 + tester.printSummary(); 11.70 + if (tester.getWarningOutput().contains("warning - Error fetching URL")) { 11.71 + throw new Error("URL rejected ?"); 11.72 + } 11.73 tester.printSummary(); 11.74 } 11.75
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/T8029002/MultipleUpperBoundsIncorporationTest.java Wed Apr 23 18:04:02 2014 -0700 12.3 @@ -0,0 +1,72 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. 12.11 + * 12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.15 + * version 2 for more details (a copy is included in the LICENSE file that 12.16 + * accompanied this code). 12.17 + * 12.18 + * You should have received a copy of the GNU General Public License version 12.19 + * 2 along with this work; if not, write to the Free Software Foundation, 12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.21 + * 12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.23 + * or visit www.oracle.com if you need additional information or have any 12.24 + * questions. 12.25 + */ 12.26 + 12.27 +/* 12.28 + * @test 12.29 + * @bug 8029002 12.30 + * @summary javac should take multiple upper bounds into account in incorporation 12.31 + * @compile MultipleUpperBoundsIncorporationTest.java 12.32 + */ 12.33 + 12.34 +import java.util.ArrayList; 12.35 +import java.util.List; 12.36 + 12.37 +public class MultipleUpperBoundsIncorporationTest { 12.38 + 12.39 + static class TestCase1 { 12.40 + interface Task<E extends Exception> {} 12.41 + 12.42 + class Comparator<T> {} 12.43 + 12.44 + class CustomException extends Exception {} 12.45 + 12.46 + class TaskQueue<E extends Exception, T extends Task<E>> {} 12.47 + 12.48 + abstract class Test { 12.49 + abstract <E extends Exception, T extends Task<E>> TaskQueue<E, T> create(Comparator<? super T> comparator); 12.50 + 12.51 + void f(Comparator<Task<CustomException>> comp) { 12.52 + TaskQueue<CustomException, Task<CustomException>> queue = create(comp); 12.53 + queue.getClass(); 12.54 + } 12.55 + } 12.56 + } 12.57 + 12.58 + static class TestCase2 { 12.59 + public <T, E extends List<T>> E typedNull() { 12.60 + return null; 12.61 + } 12.62 + 12.63 + public void call() { 12.64 + ArrayList<String> list = typedNull(); 12.65 + } 12.66 + } 12.67 + 12.68 + static class TestCase3 { 12.69 + interface I extends Iterable<String> {} 12.70 + 12.71 + <T, Exp extends Iterable<T>> Exp typedNull() { return null; } 12.72 + I i = typedNull(); 12.73 + } 12.74 + 12.75 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/diags/examples/LambdaBodyNeitherValueNorVoidCompatible.java Wed Apr 23 18:04:02 2014 -0700 13.3 @@ -0,0 +1,46 @@ 13.4 +/* 13.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.7 + * 13.8 + * This code is free software; you can redistribute it and/or modify it 13.9 + * under the terms of the GNU General Public License version 2 only, as 13.10 + * published by the Free Software Foundation. 13.11 + * 13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13.15 + * version 2 for more details (a copy is included in the LICENSE file that 13.16 + * accompanied this code). 13.17 + * 13.18 + * You should have received a copy of the GNU General Public License version 13.19 + * 2 along with this work; if not, write to the Free Software Foundation, 13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 13.21 + * 13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 13.23 + * or visit www.oracle.com if you need additional information or have any 13.24 + * questions. 13.25 + */ 13.26 + 13.27 +// key: compiler.err.lambda.body.neither.value.nor.void.compatible 13.28 +// key: compiler.err.cant.apply.symbol 13.29 +// key: compiler.misc.incompatible.ret.type.in.lambda 13.30 +// key: compiler.misc.missing.ret.val 13.31 +// key: compiler.misc.no.conforming.assignment.exists 13.32 + 13.33 +class LambdaBodyNeitherValueNorVoidCompatible { 13.34 + interface I { 13.35 + String f(String x); 13.36 + } 13.37 + 13.38 + static void foo(I i) {} 13.39 + 13.40 + void m() { 13.41 + foo((x) -> { 13.42 + if (x == null) { 13.43 + return; 13.44 + } else { 13.45 + return x; 13.46 + } 13.47 + }); 13.48 + } 13.49 +}
14.1 --- a/test/tools/javac/lambda/ErroneousLambdaExpr.java Wed Apr 23 11:35:48 2014 -0700 14.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 14.3 @@ -1,66 +0,0 @@ 14.4 -/* 14.5 - * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved. 14.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 - * 14.8 - * This code is free software; you can redistribute it and/or modify it 14.9 - * under the terms of the GNU General Public License version 2 only, as 14.10 - * published by the Free Software Foundation. 14.11 - * 14.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 14.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.15 - * version 2 for more details (a copy is included in the LICENSE file that 14.16 - * accompanied this code). 14.17 - * 14.18 - * You should have received a copy of the GNU General Public License version 14.19 - * 2 along with this work; if not, write to the Free Software Foundation, 14.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.21 - * 14.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 14.23 - * or visit www.oracle.com if you need additional information or have any 14.24 - * questions. 14.25 - */ 14.26 - 14.27 -/* 14.28 - * @test 14.29 - * @bug 8003280 14.30 - * @summary Add lambda tests 14.31 - * stale state after speculative attribution round leads to missing classfiles 14.32 - * @compile/fail/ref=ErroneousLambdaExpr.out -XDrawDiagnostics ErroneousLambdaExpr.java 14.33 - */ 14.34 -public class ErroneousLambdaExpr<T> { 14.35 - 14.36 - static int assertionCount = 0; 14.37 - 14.38 - static void assertTrue(boolean cond) { 14.39 - assertionCount++; 14.40 - if (!cond) 14.41 - throw new AssertionError(); 14.42 - } 14.43 - 14.44 - interface SAM1<X> { 14.45 - X m(X t, String s); 14.46 - } 14.47 - 14.48 - interface SAM2 { 14.49 - void m(String s, int i); 14.50 - } 14.51 - 14.52 - interface SAM3<X> { 14.53 - X m(X t, String s, int i); 14.54 - } 14.55 - 14.56 - void call(SAM1<T> s1) { assertTrue(true); } 14.57 - 14.58 - void call(SAM2 s2) { assertTrue(false); } 14.59 - 14.60 - void call(SAM3<T> s3) { assertTrue(false); } 14.61 - 14.62 - public static void main(String[] args) { 14.63 - ErroneousLambdaExpr<StringBuilder> test = 14.64 - new ErroneousLambdaExpr<>(); 14.65 - 14.66 - test.call((builder, string) -> { builder.append(string); return builder; }); 14.67 - assertTrue(assertionCount == 1); 14.68 - } 14.69 -}
15.1 --- a/test/tools/javac/lambda/ErroneousLambdaExpr.out Wed Apr 23 11:35:48 2014 -0700 15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 15.3 @@ -1,2 +0,0 @@ 15.4 -ErroneousLambdaExpr.java:63:13: compiler.err.ref.ambiguous: call, kindname.method, call(ErroneousLambdaExpr.SAM1<T>), ErroneousLambdaExpr, kindname.method, call(ErroneousLambdaExpr.SAM2), ErroneousLambdaExpr 15.5 -1 error
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Wed Apr 23 18:04:02 2014 -0700 16.3 @@ -0,0 +1,66 @@ 16.4 +/* 16.5 + * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. 16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 16.7 + * 16.8 + * This code is free software; you can redistribute it and/or modify it 16.9 + * under the terms of the GNU General Public License version 2 only, as 16.10 + * published by the Free Software Foundation. 16.11 + * 16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16.15 + * version 2 for more details (a copy is included in the LICENSE file that 16.16 + * accompanied this code). 16.17 + * 16.18 + * You should have received a copy of the GNU General Public License version 16.19 + * 2 along with this work; if not, write to the Free Software Foundation, 16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16.21 + * 16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 16.23 + * or visit www.oracle.com if you need additional information or have any 16.24 + * questions. 16.25 + */ 16.26 + 16.27 +/* 16.28 + * @test 16.29 + * @bug 8003280 16.30 + * @summary Add lambda tests 16.31 + * stale state after speculative attribution round leads to missing classfiles 16.32 + */ 16.33 +public class LambdaExprLeadsToMissingClassFilesTest<T> { 16.34 + 16.35 + static int assertionCount = 0; 16.36 + 16.37 + static void assertTrue(boolean cond) { 16.38 + assertionCount++; 16.39 + if (!cond) { 16.40 + throw new AssertionError(); 16.41 + } 16.42 + } 16.43 + 16.44 + interface SAM1<X> { 16.45 + X m(X t, String s); 16.46 + } 16.47 + 16.48 + interface SAM2 { 16.49 + void m(String s, int i); 16.50 + } 16.51 + 16.52 + interface SAM3<X> { 16.53 + X m(X t, String s, int i); 16.54 + } 16.55 + 16.56 + void call(SAM1<T> s1) { assertTrue(true); } 16.57 + 16.58 + void call(SAM2 s2) { assertTrue(false); } 16.59 + 16.60 + void call(SAM3<T> s3) { assertTrue(false); } 16.61 + 16.62 + public static void main(String[] args) { 16.63 + LambdaExprLeadsToMissingClassFilesTest<StringBuilder> test = 16.64 + new LambdaExprLeadsToMissingClassFilesTest<>(); 16.65 + 16.66 + test.call((builder, string) -> { builder.append(string); return builder; }); 16.67 + assertTrue(assertionCount == 1); 16.68 + } 16.69 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/tools/javac/lambda/MostSpecific09.java Wed Apr 23 18:04:02 2014 -0700 17.3 @@ -0,0 +1,81 @@ 17.4 +/* 17.5 + * @test /nodynamiccopyright/ 17.6 + * @bug 8029718 17.7 + * @summary Should always use lambda body structure to disambiguate overload resolution 17.8 + * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -XDshouldStopPolicy=ATTR -XDverboseResolution=applicable,success MostSpecific09.java 17.9 + */ 17.10 + 17.11 +class MostSpecific09 { 17.12 + 17.13 + interface I { 17.14 + String xoo(String x); 17.15 + } 17.16 + 17.17 + interface J { 17.18 + void xoo(int x); 17.19 + } 17.20 + 17.21 + static void foo(I i) {} 17.22 + static void foo(J j) {} 17.23 + 17.24 + static void moo(I i) {} 17.25 + static void moo(J j) {} 17.26 + 17.27 + void m() { 17.28 + foo((x) -> { return x += 1; }); 17.29 + foo((x) -> { return ""; }); 17.30 + foo((x) -> { System.out.println(""); }); 17.31 + foo((x) -> { return ""; System.out.println(""); }); 17.32 + foo((x) -> { throw new RuntimeException(); }); 17.33 + foo((x) -> { while (true); }); 17.34 + 17.35 + foo((x) -> x += 1); 17.36 + foo((x) -> ""); 17.37 + } 17.38 + 17.39 + /* any return statement that is not in the body of the lambda but in an 17.40 + * inner class or another lambda should be ignored for value void compatibility 17.41 + * determination. 17.42 + */ 17.43 + void m1() { 17.44 + boolean cond = true; 17.45 + foo((x) -> { 17.46 + if (cond) { 17.47 + return ""; 17.48 + } 17.49 + System.out.println(""); 17.50 + }); 17.51 + 17.52 + foo((x)->{ 17.53 + class Bar { 17.54 + String m() { 17.55 + return "from Bar.m()"; 17.56 + } 17.57 + } 17.58 + class Boo { 17.59 + Bar b = new Bar (){ 17.60 + String m() { 17.61 + return "from Bar$1.m()"; 17.62 + } 17.63 + }; 17.64 + } 17.65 + moo((y) -> { return ""; }); 17.66 + return; 17.67 + }); 17.68 + 17.69 + foo((x)->{ 17.70 + class Bar { 17.71 + void m() {} 17.72 + } 17.73 + class Boo { 17.74 + Bar b = new Bar (){ 17.75 + void m() { 17.76 + return; 17.77 + } 17.78 + }; 17.79 + } 17.80 + moo((y) -> { System.out.println(""); }); 17.81 + return ""; 17.82 + }); 17.83 + } 17.84 +}
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/tools/javac/lambda/MostSpecific09.out Wed Apr 23 18:04:02 2014 -0700 18.3 @@ -0,0 +1,27 @@ 18.4 +MostSpecific09.java:25:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 18.5 +MostSpecific09.java:26:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 18.6 +MostSpecific09.java:27:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} 18.7 +MostSpecific09.java:27:32: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 18.8 +MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible 18.9 +MostSpecific09.java:28:9: compiler.err.cant.apply.symbols: kindname.method, foo, @680,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} 18.10 +MostSpecific09.java:28:43: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 18.11 +MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 18.12 +MostSpecific09.java:29:28: compiler.note.verbose.resolve.multi: <init>, java.lang.RuntimeException, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, java.lang.RuntimeException(), null)} 18.13 +MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 18.14 +MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 18.15 +MostSpecific09.java:33:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 18.16 +MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible 18.17 +MostSpecific09.java:42:9: compiler.err.cant.apply.symbols: kindname.method, foo, @1129,{(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.I), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.missing.ret.val: java.lang.String)))),(compiler.misc.inapplicable.method: kindname.method, MostSpecific09, foo(MostSpecific09.J), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.unexpected.ret.val)))} 18.18 +MostSpecific09.java:46:23: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 18.19 +MostSpecific09.java:49:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.J), null)} 18.20 +MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 18.21 +MostSpecific09.java:56:35: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 18.22 +MostSpecific09.java:56:25: compiler.note.verbose.resolve.multi: <init>, compiler.misc.anonymous.class: MostSpecific09$1Boo$1, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, compiler.misc.anonymous.class: MostSpecific09$1Boo$1(), null)} 18.23 +MostSpecific09.java:62:13: compiler.note.verbose.resolve.multi: moo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, moo(MostSpecific09.I), null)} 18.24 +MostSpecific09.java:66:9: compiler.note.verbose.resolve.multi: foo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, foo(MostSpecific09.I), null)} 18.25 +MostSpecific09.java:71:25: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 18.26 +MostSpecific09.java:71:35: compiler.note.verbose.resolve.multi: <init>, Bar, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, Bar(), null)} 18.27 +MostSpecific09.java:71:25: compiler.note.verbose.resolve.multi: <init>, compiler.misc.anonymous.class: MostSpecific09$2Boo$1, 0, BASIC, compiler.misc.no.args, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, compiler.misc.anonymous.class: MostSpecific09$2Boo$1(), null)} 18.28 +MostSpecific09.java:77:13: compiler.note.verbose.resolve.multi: moo, MostSpecific09, 0, BASIC, compiler.misc.type.none, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, moo(MostSpecific09.J), null)} 18.29 +MostSpecific09.java:77:36: compiler.note.verbose.resolve.multi: println, java.io.PrintStream, 1, BASIC, java.lang.String, compiler.misc.no.args,{(compiler.misc.applicable.method.found: 0, println(java.lang.Object), null),(compiler.misc.applicable.method.found: 1, println(java.lang.String), null)} 18.30 +7 errors
19.1 --- a/test/tools/javac/lambda/TargetType01.java Wed Apr 23 11:35:48 2014 -0700 19.2 +++ b/test/tools/javac/lambda/TargetType01.java Wed Apr 23 18:04:02 2014 -0700 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 19.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 19.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.8 * 19.9 * This code is free software; you can redistribute it and/or modify it 19.10 @@ -42,6 +42,10 @@ 19.11 static String M(F_S_S f){ return null; } 19.12 19.13 static { 19.14 - M(x1 -> { return M( x2 -> { return x1 + x2; });}); //ambiguous 19.15 + M(x1 -> { 19.16 + return M( x2 -> { 19.17 + return x1 + x2; 19.18 + }); 19.19 + }); //ambiguous 19.20 } 19.21 }
20.1 --- a/test/tools/javac/lambda/TargetType01.out Wed Apr 23 11:35:48 2014 -0700 20.2 +++ b/test/tools/javac/lambda/TargetType01.out Wed Apr 23 18:04:02 2014 -0700 20.3 @@ -1,3 +1,3 @@ 20.4 TargetType01.java:45:9: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 20.5 -TargetType01.java:45:26: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 20.6 +TargetType01.java:46:20: compiler.err.ref.ambiguous: M, kindname.method, M(TargetType01.F_I_I), TargetType01, kindname.method, M(TargetType01.F_S_S), TargetType01 20.7 2 errors
21.1 --- a/test/tools/javac/lambda/TargetType02.java Wed Apr 23 11:35:48 2014 -0700 21.2 +++ b/test/tools/javac/lambda/TargetType02.java Wed Apr 23 18:04:02 2014 -0700 21.3 @@ -1,31 +1,9 @@ 21.4 /* 21.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21.23 - * or visit www.oracle.com if you need additional information or have any 21.24 - * questions. 21.25 - */ 21.26 - 21.27 -/* 21.28 - * @test 21.29 - * @bug 8003280 21.30 + * @test /nodynamiccopyright/ 21.31 + * @bug 8003280 8029718 21.32 * @summary Add lambda tests 21.33 * check overload resolution and target type inference w.r.t. generic methods 21.34 + * Should always use lambda body structure to disambiguate overload resolution 21.35 * @author Maurizio Cimadamore 21.36 * @compile/fail/ref=TargetType02.out -XDrawDiagnostics TargetType02.java 21.37 */ 21.38 @@ -47,9 +25,18 @@ 21.39 static <Z extends Number> void call3(S1<Z> s) { } 21.40 static <Z extends String> void call3(S2<Z> s) { } 21.41 21.42 + static <Z extends Number> Z call4(S1<Z> s) { return null; } 21.43 + static <Z extends String> Z call4(S2<Z> s) { return null; } 21.44 + 21.45 void test() { 21.46 call1(i -> { toString(); return i; }); 21.47 call2(i -> { toString(); return i; }); 21.48 call3(i -> { toString(); return i; }); 21.49 + call3(i -> { 21.50 + toString(); 21.51 + return call4(j -> { 21.52 + return j; 21.53 + }); 21.54 + }); 21.55 } 21.56 }
22.1 --- a/test/tools/javac/lambda/TargetType02.out Wed Apr 23 11:35:48 2014 -0700 22.2 +++ b/test/tools/javac/lambda/TargetType02.out Wed Apr 23 18:04:02 2014 -0700 22.3 @@ -1,3 +1,5 @@ 22.4 -TargetType02.java:52:14: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String) 22.5 -TargetType02.java:53:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 22.6 -2 errors 22.7 +TargetType02.java:33:14: compiler.err.prob.found.req: (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String) 22.8 +TargetType02.java:34:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 22.9 +TargetType02.java:35:9: compiler.err.ref.ambiguous: call3, kindname.method, <Z>call3(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call3(TargetType02.S2<Z>), TargetType02 22.10 +TargetType02.java:37:20: compiler.err.ref.ambiguous: call4, kindname.method, <Z>call4(TargetType02.S1<Z>), TargetType02, kindname.method, <Z>call4(TargetType02.S2<Z>), TargetType02 22.11 +4 errors
23.1 --- a/test/tools/javac/lambda/TargetType21.out Wed Apr 23 11:35:48 2014 -0700 23.2 +++ b/test/tools/javac/lambda/TargetType21.out Wed Apr 23 18:04:02 2014 -0700 23.3 @@ -1,7 +1,5 @@ 23.4 TargetType21.java:28:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 23.5 -TargetType21.java:31:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 23.6 -TargetType21.java:32:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 23.7 -TargetType21.java:32:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @888, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) 23.8 -TargetType21.java:33:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM2), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 23.9 -TargetType21.java:33:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM2, @946, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.unexpected.ret.val))) 23.10 -6 errors 23.11 +TargetType21.java:32:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 23.12 +TargetType21.java:32:13: compiler.err.cant.apply.symbol: kindname.method, call, TargetType21.SAM1, @888, kindname.class, TargetType21, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: java.lang.Object, java.lang.String))) 23.13 +TargetType21.java:33:9: compiler.err.ref.ambiguous: call, kindname.method, call(TargetType21.SAM1), TargetType21, kindname.method, <R,A>call(TargetType21.SAM3<R,A>), TargetType21 23.14 +4 errors
24.1 --- a/test/tools/javac/lambda/TargetType42.java Wed Apr 23 11:35:48 2014 -0700 24.2 +++ b/test/tools/javac/lambda/TargetType42.java Wed Apr 23 18:04:02 2014 -0700 24.3 @@ -1,5 +1,5 @@ 24.4 /* 24.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 24.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 24.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 24.8 * 24.9 * This code is free software; you can redistribute it and/or modify it 24.10 @@ -31,12 +31,18 @@ 24.11 class TargetType42 { 24.12 24.13 interface SAM<X, Y> { 24.14 - Y f(X x); 24.15 + Y f(X x); 24.16 } 24.17 24.18 <Z> void m(SAM<String, SAM<Z, Object>> s, Z z) { } 24.19 24.20 void test(Object obj) { 24.21 - m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj); 24.22 + m((x)->{ 24.23 + class Foo { } 24.24 + return (x2)-> { 24.25 + new Foo(); 24.26 + return null; 24.27 + }; 24.28 + }, obj); 24.29 } 24.30 }
25.1 --- a/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Wed Apr 23 11:35:48 2014 -0700 25.2 +++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Wed Apr 23 18:04:02 2014 -0700 25.3 @@ -1,5 +1,5 @@ 25.4 /* 25.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 25.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 25.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 25.8 * 25.9 * This code is free software; you can redistribute it and/or modify it 25.10 @@ -33,7 +33,6 @@ 25.11 import java.util.Collections; 25.12 import java.util.List; 25.13 import java.util.ArrayList; 25.14 -import java.util.Date; 25.15 25.16 public class LambdaTest1 { 25.17
26.1 --- a/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Wed Apr 23 11:35:48 2014 -0700 26.2 +++ b/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Wed Apr 23 18:04:02 2014 -0700 26.3 @@ -1,5 +1,5 @@ 26.4 /* 26.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 26.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 26.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 26.8 * 26.9 * This code is free software; you can redistribute it and/or modify it 26.10 @@ -209,7 +209,11 @@ 26.11 final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 26.12 DiagnosticChecker dc = new DiagnosticChecker(); 26.13 JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); 26.14 - ct.analyze(); 26.15 + try { 26.16 + ct.analyze(); 26.17 + } catch (Exception e) { 26.18 + throw new AssertionError("failing SAM source file \n" + samSourceFile + "\n\n" + "failing client source file \n"+ clientSourceFile); 26.19 + } 26.20 if (dc.errorFound == checkSamConversion()) { 26.21 throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile); 26.22 }
27.1 --- a/test/tools/javadoc/parser/7091528/T7091528.java Wed Apr 23 11:35:48 2014 -0700 27.2 +++ b/test/tools/javadoc/parser/7091528/T7091528.java Wed Apr 23 18:04:02 2014 -0700 27.3 @@ -23,7 +23,7 @@ 27.4 27.5 /** 27.6 * @test 27.7 - * @bug 7091528 8029145 27.8 + * @bug 7091528 8029145 8037484 27.9 * @summary ensures javadoc parses unique source files and ignores all class files 27.10 * @compile p/C1.java p/q/C2.java 27.11 * @run main T7091528 27.12 @@ -50,6 +50,16 @@ 27.13 "-sourcepath", testSrc.getAbsolutePath(), 27.14 "-subpackages", 27.15 "p:p.q"); 27.16 + File testPkgDir = new File(testSrc, "p"); 27.17 + File testFile = new File(testPkgDir, "C3.java"); 27.18 + runTest("-d", ".", 27.19 + "-sourcepath", testSrc.getAbsolutePath(), 27.20 + testFile.getAbsolutePath(), 27.21 + "p"); 27.22 + runTest("-d", ".", 27.23 + "-classpath", testSrc.getAbsolutePath(), 27.24 + testFile.getAbsolutePath(), 27.25 + "p"); 27.26 27.27 } 27.28 void runTest(String... args) { 27.29 @@ -65,7 +75,7 @@ 27.30 } 27.31 27.32 if (rc != 0) 27.33 - System.err.println("javadoc failed: exit code = " + rc); 27.34 + throw new Error("javadoc failed: exit code = " + rc); 27.35 27.36 if (out.matches("(?s).*p/[^ ]+\\.class.*")) 27.37 throw new Error("reading .class files");
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/tools/javadoc/parser/7091528/p/C3.java Wed Apr 23 18:04:02 2014 -0700 28.3 @@ -0,0 +1,27 @@ 28.4 +/* 28.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 28.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 28.7 + * 28.8 + * This code is free software; you can redistribute it and/or modify it 28.9 + * under the terms of the GNU General Public License version 2 only, as 28.10 + * published by the Free Software Foundation. 28.11 + * 28.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 28.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 28.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 28.15 + * version 2 for more details (a copy is included in the LICENSE file that 28.16 + * accompanied this code). 28.17 + * 28.18 + * You should have received a copy of the GNU General Public License version 28.19 + * 2 along with this work; if not, write to the Free Software Foundation, 28.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 28.21 + * 28.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 28.23 + * or visit www.oracle.com if you need additional information or have any 28.24 + * questions. 28.25 + */ 28.26 + 28.27 + 28.28 +/** This is class C3, and no package for me please */ 28.29 +public class C3 {} 28.30 +