Tue, 22 Apr 2014 17:55:22 +0100
8029718: Should always use lambda body structure to disambiguate overload resolution
Reviewed-by: dlsmith, jjg, jlahoda
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Apr 18 23:58:05 2014 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Apr 22 17:55:22 2014 +0100 1.3 @@ -2618,7 +2618,7 @@ 1.4 * - an instance field, we use the first constructor. 1.5 * - a static field, we create a fake clinit method. 1.6 */ 1.7 - private Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { 1.8 + public Env<AttrContext> lambdaEnv(JCLambda that, Env<AttrContext> env) { 1.9 Env<AttrContext> lambdaEnv; 1.10 Symbol owner = env.info.scope.owner; 1.11 if (owner.kind == VAR && owner.owner.kind == TYP) {
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Apr 18 23:58:05 2014 +0100 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue Apr 22 17:55:22 2014 +0100 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -25,7 +25,7 @@ 2.11 2.12 package com.sun.tools.javac.comp; 2.13 2.14 -import com.sun.source.tree.MemberReferenceTree; 2.15 +import com.sun.source.tree.LambdaExpressionTree.BodyKind; 2.16 import com.sun.tools.javac.code.*; 2.17 import com.sun.tools.javac.tree.*; 2.18 import com.sun.tools.javac.util.*; 2.19 @@ -35,10 +35,8 @@ 2.20 import com.sun.tools.javac.comp.Attr.ResultInfo; 2.21 import com.sun.tools.javac.comp.Infer.InferenceContext; 2.22 import com.sun.tools.javac.comp.Resolve.MethodResolutionPhase; 2.23 -import com.sun.tools.javac.comp.Resolve.ReferenceLookupHelper; 2.24 import com.sun.tools.javac.tree.JCTree.*; 2.25 2.26 - 2.27 import java.util.ArrayList; 2.28 import java.util.Collections; 2.29 import java.util.EnumSet; 2.30 @@ -48,6 +46,7 @@ 2.31 import java.util.Set; 2.32 import java.util.WeakHashMap; 2.33 2.34 +import static com.sun.tools.javac.code.Kinds.VAL; 2.35 import static com.sun.tools.javac.code.TypeTag.*; 2.36 import static com.sun.tools.javac.tree.JCTree.Tag.*; 2.37 2.38 @@ -76,6 +75,8 @@ 2.39 final Symtab syms; 2.40 final TreeMaker make; 2.41 final Types types; 2.42 + final Flow flow; 2.43 + final Names names; 2.44 2.45 public static DeferredAttr instance(Context context) { 2.46 DeferredAttr instance = context.get(deferredAttrKey); 2.47 @@ -96,7 +97,8 @@ 2.48 syms = Symtab.instance(context); 2.49 make = TreeMaker.instance(context); 2.50 types = Types.instance(context); 2.51 - Names names = Names.instance(context); 2.52 + flow = Flow.instance(context); 2.53 + names = Names.instance(context); 2.54 stuckTree = make.Ident(names.empty).setType(Type.stuckType); 2.55 emptyDeferredAttrContext = 2.56 new DeferredAttrContext(AttrMode.CHECK, null, MethodResolutionPhase.BOX, infer.emptyContext, null, null) { 2.57 @@ -139,6 +141,11 @@ 2.58 return DEFERRED; 2.59 } 2.60 2.61 + @Override 2.62 + public String toString() { 2.63 + return "DeferredType"; 2.64 + } 2.65 + 2.66 /** 2.67 * A speculative cache is used to keep track of all overload resolution rounds 2.68 * that triggered speculative attribution on a given deferred type. Each entry 2.69 @@ -378,7 +385,9 @@ 2.70 } 2.71 } 2.72 //where 2.73 - protected TreeScanner unenterScanner = new TreeScanner() { 2.74 + protected UnenterScanner unenterScanner = new UnenterScanner(); 2.75 + 2.76 + class UnenterScanner extends TreeScanner { 2.77 @Override 2.78 public void visitClassDef(JCClassDecl tree) { 2.79 ClassSymbol csym = tree.sym; 2.80 @@ -391,7 +400,7 @@ 2.81 syms.classes.remove(csym.flatname); 2.82 super.visitClassDef(tree); 2.83 } 2.84 - }; 2.85 + } 2.86 2.87 /** 2.88 * A deferred context is created on each method check. A deferred context is 2.89 @@ -595,19 +604,111 @@ 2.90 public void visitLambda(JCLambda tree) { 2.91 Check.CheckContext checkContext = resultInfo.checkContext; 2.92 Type pt = resultInfo.pt; 2.93 - if (inferenceContext.inferencevars.contains(pt)) { 2.94 - //ok 2.95 - return; 2.96 - } else { 2.97 + if (!inferenceContext.inferencevars.contains(pt)) { 2.98 //must be a functional descriptor 2.99 + Type descriptorType = null; 2.100 try { 2.101 - Type desc = types.findDescriptorType(pt); 2.102 - if (desc.getParameterTypes().length() != tree.params.length()) { 2.103 - checkContext.report(tree, diags.fragment("incompatible.arg.types.in.lambda")); 2.104 - } 2.105 + descriptorType = types.findDescriptorType(pt); 2.106 } catch (Types.FunctionDescriptorLookupError ex) { 2.107 checkContext.report(null, ex.getDiagnostic()); 2.108 } 2.109 + 2.110 + if (descriptorType.getParameterTypes().length() != tree.params.length()) { 2.111 + checkContext.report(tree, 2.112 + diags.fragment("incompatible.arg.types.in.lambda")); 2.113 + } 2.114 + 2.115 + Type currentReturnType = descriptorType.getReturnType(); 2.116 + boolean returnTypeIsVoid = currentReturnType.hasTag(VOID); 2.117 + if (tree.getBodyKind() == BodyKind.EXPRESSION) { 2.118 + boolean isExpressionCompatible = !returnTypeIsVoid || 2.119 + TreeInfo.isExpressionStatement((JCExpression)tree.getBody()); 2.120 + if (!isExpressionCompatible) { 2.121 + resultInfo.checkContext.report(tree.pos(), 2.122 + diags.fragment("incompatible.ret.type.in.lambda", 2.123 + diags.fragment("missing.ret.val", currentReturnType))); 2.124 + } 2.125 + } else { 2.126 + LambdaBodyStructChecker lambdaBodyChecker = 2.127 + new LambdaBodyStructChecker(); 2.128 + 2.129 + tree.body.accept(lambdaBodyChecker); 2.130 + boolean isVoidCompatible = lambdaBodyChecker.isVoidCompatible; 2.131 + 2.132 + if (returnTypeIsVoid) { 2.133 + if (!isVoidCompatible) { 2.134 + resultInfo.checkContext.report(tree.pos(), 2.135 + diags.fragment("unexpected.ret.val")); 2.136 + } 2.137 + } else { 2.138 + boolean isValueCompatible = lambdaBodyChecker.isPotentiallyValueCompatible 2.139 + && !canLambdaBodyCompleteNormally(tree); 2.140 + if (!isValueCompatible && !isVoidCompatible) { 2.141 + log.error(tree.body.pos(), 2.142 + "lambda.body.neither.value.nor.void.compatible"); 2.143 + } 2.144 + 2.145 + if (!isValueCompatible) { 2.146 + resultInfo.checkContext.report(tree.pos(), 2.147 + diags.fragment("incompatible.ret.type.in.lambda", 2.148 + diags.fragment("missing.ret.val", currentReturnType))); 2.149 + } 2.150 + } 2.151 + } 2.152 + } 2.153 + } 2.154 + 2.155 + boolean canLambdaBodyCompleteNormally(JCLambda tree) { 2.156 + JCLambda newTree = new TreeCopier<>(make).copy(tree); 2.157 + /* attr.lambdaEnv will create a meaningful env for the 2.158 + * lambda expression. This is specially useful when the 2.159 + * lambda is used as the init of a field. But we need to 2.160 + * remove any added symbol. 2.161 + */ 2.162 + Env<AttrContext> localEnv = attr.lambdaEnv(newTree, env); 2.163 + try { 2.164 + List<JCVariableDecl> tmpParams = newTree.params; 2.165 + while (tmpParams.nonEmpty()) { 2.166 + tmpParams.head.vartype = make.at(tmpParams.head).Type(syms.errType); 2.167 + tmpParams = tmpParams.tail; 2.168 + } 2.169 + 2.170 + attr.attribStats(newTree.params, localEnv); 2.171 + 2.172 + /* set pt to Type.noType to avoid generating any bound 2.173 + * which may happen if lambda's return type is an 2.174 + * inference variable 2.175 + */ 2.176 + Attr.ResultInfo bodyResultInfo = attr.new ResultInfo(VAL, Type.noType); 2.177 + localEnv.info.returnResult = bodyResultInfo; 2.178 + 2.179 + // discard any log output 2.180 + Log.DiagnosticHandler diagHandler = new Log.DiscardDiagnosticHandler(log); 2.181 + try { 2.182 + JCBlock body = (JCBlock)newTree.body; 2.183 + /* we need to attribute the lambda body before 2.184 + * doing the aliveness analysis. This is because 2.185 + * constant folding occurs during attribution 2.186 + * and the reachability of some statements depends 2.187 + * on constant values, for example: 2.188 + * 2.189 + * while (true) {...} 2.190 + */ 2.191 + attr.attribStats(body.stats, localEnv); 2.192 + 2.193 + attr.preFlow(newTree); 2.194 + /* make an aliveness / reachability analysis of the lambda 2.195 + * to determine if it can complete normally 2.196 + */ 2.197 + flow.analyzeLambda(localEnv, newTree, make, true); 2.198 + } finally { 2.199 + log.popDiagnosticHandler(diagHandler); 2.200 + } 2.201 + return newTree.canCompleteNormally; 2.202 + } finally { 2.203 + JCBlock body = (JCBlock)newTree.body; 2.204 + unenterScanner.scan(body.stats); 2.205 + localEnv.info.scope.leave(); 2.206 } 2.207 } 2.208 2.209 @@ -625,10 +726,7 @@ 2.210 public void visitReference(JCMemberReference tree) { 2.211 Check.CheckContext checkContext = resultInfo.checkContext; 2.212 Type pt = resultInfo.pt; 2.213 - if (inferenceContext.inferencevars.contains(pt)) { 2.214 - //ok 2.215 - return; 2.216 - } else { 2.217 + if (!inferenceContext.inferencevars.contains(pt)) { 2.218 try { 2.219 types.findDescriptorType(pt); 2.220 } catch (Types.FunctionDescriptorLookupError ex) { 2.221 @@ -658,6 +756,40 @@ 2.222 } 2.223 } 2.224 } 2.225 + 2.226 + /* This visitor looks for return statements, its analysis will determine if 2.227 + * a lambda body is void or value compatible. We must analyze return 2.228 + * statements contained in the lambda body only, thus any return statement 2.229 + * contained in an inner class or inner lambda body, should be ignored. 2.230 + */ 2.231 + class LambdaBodyStructChecker extends TreeScanner { 2.232 + boolean isVoidCompatible = true; 2.233 + boolean isPotentiallyValueCompatible = true; 2.234 + 2.235 + @Override 2.236 + public void visitClassDef(JCClassDecl tree) { 2.237 + // do nothing 2.238 + } 2.239 + 2.240 + @Override 2.241 + public void visitLambda(JCLambda tree) { 2.242 + // do nothing 2.243 + } 2.244 + 2.245 + @Override 2.246 + public void visitNewClass(JCNewClass tree) { 2.247 + // do nothing 2.248 + } 2.249 + 2.250 + @Override 2.251 + public void visitReturn(JCReturn tree) { 2.252 + if (tree.expr != null) { 2.253 + isVoidCompatible = false; 2.254 + } else { 2.255 + isPotentiallyValueCompatible = false; 2.256 + } 2.257 + } 2.258 + } 2.259 } 2.260 2.261 /** an empty deferred attribution context - all methods throw exceptions */ 2.262 @@ -769,7 +901,7 @@ 2.263 /** 2.264 * handler that is executed when a node has been discarded 2.265 */ 2.266 - abstract void skip(JCTree tree); 2.267 + void skip(JCTree tree) {} 2.268 } 2.269 2.270 /** 2.271 @@ -781,11 +913,6 @@ 2.272 PolyScanner() { 2.273 super(EnumSet.of(CONDEXPR, PARENS, LAMBDA, REFERENCE)); 2.274 } 2.275 - 2.276 - @Override 2.277 - void skip(JCTree tree) { 2.278 - //do nothing 2.279 - } 2.280 } 2.281 2.282 /** 2.283 @@ -798,11 +925,6 @@ 2.284 super(EnumSet.of(BLOCK, CASE, CATCH, DOLOOP, FOREACHLOOP, 2.285 FORLOOP, RETURN, SYNCHRONIZED, SWITCH, TRY, WHILELOOP)); 2.286 } 2.287 - 2.288 - @Override 2.289 - void skip(JCTree tree) { 2.290 - //do nothing 2.291 - } 2.292 } 2.293 2.294 /**
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Apr 18 23:58:05 2014 +0100 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Apr 22 17:55:22 2014 +0100 3.3 @@ -45,7 +45,7 @@ 3.4 import static com.sun.tools.javac.tree.JCTree.Tag.*; 3.5 3.6 /** This pass implements dataflow analysis for Java programs though 3.7 - * different AST visitor steps. Liveness analysis (see AliveAlanyzer) checks that 3.8 + * different AST visitor steps. Liveness analysis (see AliveAnalyzer) checks that 3.9 * every statement is reachable. Exception analysis (see FlowAnalyzer) ensures that 3.10 * every checked exception that is thrown is declared or caught. Definite assignment analysis 3.11 * (see AssignAnalyzer) ensures that each variable is assigned when used. Definite
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Apr 18 23:58:05 2014 +0100 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Apr 22 17:55:22 2014 +0100 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -2360,6 +2360,7 @@ 4.11 /** Visitor method: Translate a single node. 4.12 * Attach the source position from the old tree to its replacement tree. 4.13 */ 4.14 + @Override 4.15 public <T extends JCTree> T translate(T tree) { 4.16 if (tree == null) { 4.17 return null;
5.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Apr 18 23:58:05 2014 +0100 5.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Apr 22 17:55:22 2014 +0100 5.3 @@ -1,5 +1,5 @@ 5.4 # 5.5 -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 5.6 +# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. 5.7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 # 5.9 # This code is free software; you can redistribute it and/or modify it 5.10 @@ -735,6 +735,9 @@ 5.11 bad return type in method reference\n\ 5.12 {0} 5.13 5.14 +compiler.err.lambda.body.neither.value.nor.void.compatible=\ 5.15 + lambda body is neither value nor void compatible 5.16 + 5.17 # 0: list of type 5.18 compiler.err.incompatible.thrown.types.in.mref=\ 5.19 incompatible thrown types {0} in method reference
6.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Fri Apr 18 23:58:05 2014 +0100 6.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeTranslator.java Tue Apr 22 17:55:22 2014 +0100 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 @@ -56,9 +56,9 @@ 6.11 return null; 6.12 } else { 6.13 tree.accept(this); 6.14 - JCTree result = this.result; 6.15 + JCTree tmpResult = this.result; 6.16 this.result = null; 6.17 - return (T)result; // XXX cast 6.18 + return (T)tmpResult; // XXX cast 6.19 } 6.20 } 6.21
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/tools/javac/diags/examples/LambdaBodyNeitherValueNorVoidCompatible.java Tue Apr 22 17:55:22 2014 +0100 7.3 @@ -0,0 +1,46 @@ 7.4 +/* 7.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 7.23 + * or visit www.oracle.com if you need additional information or have any 7.24 + * questions. 7.25 + */ 7.26 + 7.27 +// key: compiler.err.lambda.body.neither.value.nor.void.compatible 7.28 +// key: compiler.err.cant.apply.symbol 7.29 +// key: compiler.misc.incompatible.ret.type.in.lambda 7.30 +// key: compiler.misc.missing.ret.val 7.31 +// key: compiler.misc.no.conforming.assignment.exists 7.32 + 7.33 +class LambdaBodyNeitherValueNorVoidCompatible { 7.34 + interface I { 7.35 + String f(String x); 7.36 + } 7.37 + 7.38 + static void foo(I i) {} 7.39 + 7.40 + void m() { 7.41 + foo((x) -> { 7.42 + if (x == null) { 7.43 + return; 7.44 + } else { 7.45 + return x; 7.46 + } 7.47 + }); 7.48 + } 7.49 +}
8.1 --- a/test/tools/javac/lambda/ErroneousLambdaExpr.java Fri Apr 18 23:58:05 2014 +0100 8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 8.3 @@ -1,66 +0,0 @@ 8.4 -/* 8.5 - * Copyright (c) 2012, 2013 Oracle and/or its affiliates. All rights reserved. 8.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 8.7 - * 8.8 - * This code is free software; you can redistribute it and/or modify it 8.9 - * under the terms of the GNU General Public License version 2 only, as 8.10 - * published by the Free Software Foundation. 8.11 - * 8.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 8.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 8.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 8.15 - * version 2 for more details (a copy is included in the LICENSE file that 8.16 - * accompanied this code). 8.17 - * 8.18 - * You should have received a copy of the GNU General Public License version 8.19 - * 2 along with this work; if not, write to the Free Software Foundation, 8.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 8.21 - * 8.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 8.23 - * or visit www.oracle.com if you need additional information or have any 8.24 - * questions. 8.25 - */ 8.26 - 8.27 -/* 8.28 - * @test 8.29 - * @bug 8003280 8.30 - * @summary Add lambda tests 8.31 - * stale state after speculative attribution round leads to missing classfiles 8.32 - * @compile/fail/ref=ErroneousLambdaExpr.out -XDrawDiagnostics ErroneousLambdaExpr.java 8.33 - */ 8.34 -public class ErroneousLambdaExpr<T> { 8.35 - 8.36 - static int assertionCount = 0; 8.37 - 8.38 - static void assertTrue(boolean cond) { 8.39 - assertionCount++; 8.40 - if (!cond) 8.41 - throw new AssertionError(); 8.42 - } 8.43 - 8.44 - interface SAM1<X> { 8.45 - X m(X t, String s); 8.46 - } 8.47 - 8.48 - interface SAM2 { 8.49 - void m(String s, int i); 8.50 - } 8.51 - 8.52 - interface SAM3<X> { 8.53 - X m(X t, String s, int i); 8.54 - } 8.55 - 8.56 - void call(SAM1<T> s1) { assertTrue(true); } 8.57 - 8.58 - void call(SAM2 s2) { assertTrue(false); } 8.59 - 8.60 - void call(SAM3<T> s3) { assertTrue(false); } 8.61 - 8.62 - public static void main(String[] args) { 8.63 - ErroneousLambdaExpr<StringBuilder> test = 8.64 - new ErroneousLambdaExpr<>(); 8.65 - 8.66 - test.call((builder, string) -> { builder.append(string); return builder; }); 8.67 - assertTrue(assertionCount == 1); 8.68 - } 8.69 -}
9.1 --- a/test/tools/javac/lambda/ErroneousLambdaExpr.out Fri Apr 18 23:58:05 2014 +0100 9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 9.3 @@ -1,2 +0,0 @@ 9.4 -ErroneousLambdaExpr.java:63:13: compiler.err.ref.ambiguous: call, kindname.method, call(ErroneousLambdaExpr.SAM1<T>), ErroneousLambdaExpr, kindname.method, call(ErroneousLambdaExpr.SAM2), ErroneousLambdaExpr 9.5 -1 error
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/lambda/LambdaExprLeadsToMissingClassFilesTest.java Tue Apr 22 17:55:22 2014 +0100 10.3 @@ -0,0 +1,66 @@ 10.4 +/* 10.5 + * Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved. 10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 10.7 + * 10.8 + * This code is free software; you can redistribute it and/or modify it 10.9 + * under the terms of the GNU General Public License version 2 only, as 10.10 + * published by the Free Software Foundation. 10.11 + * 10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.15 + * version 2 for more details (a copy is included in the LICENSE file that 10.16 + * accompanied this code). 10.17 + * 10.18 + * You should have received a copy of the GNU General Public License version 10.19 + * 2 along with this work; if not, write to the Free Software Foundation, 10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.21 + * 10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.23 + * or visit www.oracle.com if you need additional information or have any 10.24 + * questions. 10.25 + */ 10.26 + 10.27 +/* 10.28 + * @test 10.29 + * @bug 8003280 10.30 + * @summary Add lambda tests 10.31 + * stale state after speculative attribution round leads to missing classfiles 10.32 + */ 10.33 +public class LambdaExprLeadsToMissingClassFilesTest<T> { 10.34 + 10.35 + static int assertionCount = 0; 10.36 + 10.37 + static void assertTrue(boolean cond) { 10.38 + assertionCount++; 10.39 + if (!cond) { 10.40 + throw new AssertionError(); 10.41 + } 10.42 + } 10.43 + 10.44 + interface SAM1<X> { 10.45 + X m(X t, String s); 10.46 + } 10.47 + 10.48 + interface SAM2 { 10.49 + void m(String s, int i); 10.50 + } 10.51 + 10.52 + interface SAM3<X> { 10.53 + X m(X t, String s, int i); 10.54 + } 10.55 + 10.56 + void call(SAM1<T> s1) { assertTrue(true); } 10.57 + 10.58 + void call(SAM2 s2) { assertTrue(false); } 10.59 + 10.60 + void call(SAM3<T> s3) { assertTrue(false); } 10.61 + 10.62 + public static void main(String[] args) { 10.63 + LambdaExprLeadsToMissingClassFilesTest<StringBuilder> test = 10.64 + new LambdaExprLeadsToMissingClassFilesTest<>(); 10.65 + 10.66 + test.call((builder, string) -> { builder.append(string); return builder; }); 10.67 + assertTrue(assertionCount == 1); 10.68 + } 10.69 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/lambda/MostSpecific09.java Tue Apr 22 17:55:22 2014 +0100 11.3 @@ -0,0 +1,81 @@ 11.4 +/* 11.5 + * @test /nodynamiccopyright/ 11.6 + * @bug 8029718 11.7 + * @summary Should always use lambda body structure to disambiguate overload resolution 11.8 + * @compile/fail/ref=MostSpecific09.out -XDrawDiagnostics -XDshouldStopPolicy=ATTR -XDverboseResolution=applicable,success MostSpecific09.java 11.9 + */ 11.10 + 11.11 +class MostSpecific09 { 11.12 + 11.13 + interface I { 11.14 + String xoo(String x); 11.15 + } 11.16 + 11.17 + interface J { 11.18 + void xoo(int x); 11.19 + } 11.20 + 11.21 + static void foo(I i) {} 11.22 + static void foo(J j) {} 11.23 + 11.24 + static void moo(I i) {} 11.25 + static void moo(J j) {} 11.26 + 11.27 + void m() { 11.28 + foo((x) -> { return x += 1; }); 11.29 + foo((x) -> { return ""; }); 11.30 + foo((x) -> { System.out.println(""); }); 11.31 + foo((x) -> { return ""; System.out.println(""); }); 11.32 + foo((x) -> { throw new RuntimeException(); }); 11.33 + foo((x) -> { while (true); }); 11.34 + 11.35 + foo((x) -> x += 1); 11.36 + foo((x) -> ""); 11.37 + } 11.38 + 11.39 + /* any return statement that is not in the body of the lambda but in an 11.40 + * inner class or another lambda should be ignored for value void compatibility 11.41 + * determination. 11.42 + */ 11.43 + void m1() { 11.44 + boolean cond = true; 11.45 + foo((x) -> { 11.46 + if (cond) { 11.47 + return ""; 11.48 + } 11.49 + System.out.println(""); 11.50 + }); 11.51 + 11.52 + foo((x)->{ 11.53 + class Bar { 11.54 + String m() { 11.55 + return "from Bar.m()"; 11.56 + } 11.57 + } 11.58 + class Boo { 11.59 + Bar b = new Bar (){ 11.60 + String m() { 11.61 + return "from Bar$1.m()"; 11.62 + } 11.63 + }; 11.64 + } 11.65 + moo((y) -> { return ""; }); 11.66 + return; 11.67 + }); 11.68 + 11.69 + foo((x)->{ 11.70 + class Bar { 11.71 + void m() {} 11.72 + } 11.73 + class Boo { 11.74 + Bar b = new Bar (){ 11.75 + void m() { 11.76 + return; 11.77 + } 11.78 + }; 11.79 + } 11.80 + moo((y) -> { System.out.println(""); }); 11.81 + return ""; 11.82 + }); 11.83 + } 11.84 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/lambda/MostSpecific09.out Tue Apr 22 17:55:22 2014 +0100 12.3 @@ -0,0 +1,27 @@ 12.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)} 12.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)} 12.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)} 12.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)} 12.8 +MostSpecific09.java:28:13: compiler.err.lambda.body.neither.value.nor.void.compatible 12.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)))} 12.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)} 12.11 +MostSpecific09.java:29:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 12.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)} 12.13 +MostSpecific09.java:30:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 12.14 +MostSpecific09.java:32:9: compiler.err.ref.ambiguous: foo, kindname.method, foo(MostSpecific09.I), MostSpecific09, kindname.method, foo(MostSpecific09.J), MostSpecific09 12.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)} 12.16 +MostSpecific09.java:42:13: compiler.err.lambda.body.neither.value.nor.void.compatible 12.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)))} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.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)} 12.30 +7 errors
13.1 --- a/test/tools/javac/lambda/TargetType01.java Fri Apr 18 23:58:05 2014 +0100 13.2 +++ b/test/tools/javac/lambda/TargetType01.java Tue Apr 22 17:55:22 2014 +0100 13.3 @@ -1,5 +1,5 @@ 13.4 /* 13.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 13.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 13.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 13.8 * 13.9 * This code is free software; you can redistribute it and/or modify it 13.10 @@ -42,6 +42,10 @@ 13.11 static String M(F_S_S f){ return null; } 13.12 13.13 static { 13.14 - M(x1 -> { return M( x2 -> { return x1 + x2; });}); //ambiguous 13.15 + M(x1 -> { 13.16 + return M( x2 -> { 13.17 + return x1 + x2; 13.18 + }); 13.19 + }); //ambiguous 13.20 } 13.21 }
14.1 --- a/test/tools/javac/lambda/TargetType01.out Fri Apr 18 23:58:05 2014 +0100 14.2 +++ b/test/tools/javac/lambda/TargetType01.out Tue Apr 22 17:55:22 2014 +0100 14.3 @@ -1,3 +1,3 @@ 14.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 14.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 14.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 14.7 2 errors
15.1 --- a/test/tools/javac/lambda/TargetType02.java Fri Apr 18 23:58:05 2014 +0100 15.2 +++ b/test/tools/javac/lambda/TargetType02.java Tue Apr 22 17:55:22 2014 +0100 15.3 @@ -1,31 +1,9 @@ 15.4 /* 15.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 15.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 - * 15.8 - * This code is free software; you can redistribute it and/or modify it 15.9 - * under the terms of the GNU General Public License version 2 only, as 15.10 - * published by the Free Software Foundation. 15.11 - * 15.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 - * version 2 for more details (a copy is included in the LICENSE file that 15.16 - * accompanied this code). 15.17 - * 15.18 - * You should have received a copy of the GNU General Public License version 15.19 - * 2 along with this work; if not, write to the Free Software Foundation, 15.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 - * 15.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 15.23 - * or visit www.oracle.com if you need additional information or have any 15.24 - * questions. 15.25 - */ 15.26 - 15.27 -/* 15.28 - * @test 15.29 - * @bug 8003280 15.30 + * @test /nodynamiccopyright/ 15.31 + * @bug 8003280 8029718 15.32 * @summary Add lambda tests 15.33 * check overload resolution and target type inference w.r.t. generic methods 15.34 + * Should always use lambda body structure to disambiguate overload resolution 15.35 * @author Maurizio Cimadamore 15.36 * @compile/fail/ref=TargetType02.out -XDrawDiagnostics TargetType02.java 15.37 */ 15.38 @@ -47,9 +25,18 @@ 15.39 static <Z extends Number> void call3(S1<Z> s) { } 15.40 static <Z extends String> void call3(S2<Z> s) { } 15.41 15.42 + static <Z extends Number> Z call4(S1<Z> s) { return null; } 15.43 + static <Z extends String> Z call4(S2<Z> s) { return null; } 15.44 + 15.45 void test() { 15.46 call1(i -> { toString(); return i; }); 15.47 call2(i -> { toString(); return i; }); 15.48 call3(i -> { toString(); return i; }); 15.49 + call3(i -> { 15.50 + toString(); 15.51 + return call4(j -> { 15.52 + return j; 15.53 + }); 15.54 + }); 15.55 } 15.56 }
16.1 --- a/test/tools/javac/lambda/TargetType02.out Fri Apr 18 23:58:05 2014 +0100 16.2 +++ b/test/tools/javac/lambda/TargetType02.out Tue Apr 22 17:55:22 2014 +0100 16.3 @@ -1,3 +1,5 @@ 16.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) 16.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 16.6 -2 errors 16.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) 16.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 16.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 16.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 16.11 +4 errors
17.1 --- a/test/tools/javac/lambda/TargetType21.out Fri Apr 18 23:58:05 2014 +0100 17.2 +++ b/test/tools/javac/lambda/TargetType21.out Tue Apr 22 17:55:22 2014 +0100 17.3 @@ -1,7 +1,5 @@ 17.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 17.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 17.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 17.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))) 17.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 17.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))) 17.10 -6 errors 17.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 17.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))) 17.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 17.14 +4 errors
18.1 --- a/test/tools/javac/lambda/TargetType42.java Fri Apr 18 23:58:05 2014 +0100 18.2 +++ b/test/tools/javac/lambda/TargetType42.java Tue Apr 22 17:55:22 2014 +0100 18.3 @@ -1,5 +1,5 @@ 18.4 /* 18.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 18.6 + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 18.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.8 * 18.9 * This code is free software; you can redistribute it and/or modify it 18.10 @@ -31,12 +31,18 @@ 18.11 class TargetType42 { 18.12 18.13 interface SAM<X, Y> { 18.14 - Y f(X x); 18.15 + Y f(X x); 18.16 } 18.17 18.18 <Z> void m(SAM<String, SAM<Z, Object>> s, Z z) { } 18.19 18.20 void test(Object obj) { 18.21 - m((x)->{ class Foo { }; return (x2)-> { new Foo(); return null; }; }, obj); 18.22 + m((x)->{ 18.23 + class Foo { } 18.24 + return (x2)-> { 18.25 + new Foo(); 18.26 + return null; 18.27 + }; 18.28 + }, obj); 18.29 } 18.30 }
19.1 --- a/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Fri Apr 18 23:58:05 2014 +0100 19.2 +++ b/test/tools/javac/lambda/lambdaExpression/LambdaTest1.java Tue Apr 22 17:55:22 2014 +0100 19.3 @@ -1,5 +1,5 @@ 19.4 /* 19.5 - * Copyright (c) 2011, 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 @@ -33,7 +33,6 @@ 19.11 import java.util.Collections; 19.12 import java.util.List; 19.13 import java.util.ArrayList; 19.14 -import java.util.Date; 19.15 19.16 public class LambdaTest1 { 19.17
20.1 --- a/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Fri Apr 18 23:58:05 2014 +0100 20.2 +++ b/test/tools/javac/lambda/lambdaExpression/SamConversionComboTest.java Tue Apr 22 17:55:22 2014 +0100 20.3 @@ -1,5 +1,5 @@ 20.4 /* 20.5 - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. 20.6 + * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. 20.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.8 * 20.9 * This code is free software; you can redistribute it and/or modify it 20.10 @@ -209,7 +209,11 @@ 20.11 final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 20.12 DiagnosticChecker dc = new DiagnosticChecker(); 20.13 JavacTask ct = (JavacTask)tool.getTask(null, null, dc, null, null, Arrays.asList(samSourceFile, clientSourceFile)); 20.14 - ct.analyze(); 20.15 + try { 20.16 + ct.analyze(); 20.17 + } catch (Exception e) { 20.18 + throw new AssertionError("failing SAM source file \n" + samSourceFile + "\n\n" + "failing client source file \n"+ clientSourceFile); 20.19 + } 20.20 if (dc.errorFound == checkSamConversion()) { 20.21 throw new AssertionError(samSourceFile + "\n\n" + clientSourceFile); 20.22 }