Thu, 09 Apr 2015 22:59:11 -0700
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Wed Apr 01 11:34:59 2015 -0700 1.2 +++ b/.hgtags Thu Apr 09 22:59:11 2015 -0700 1.3 @@ -404,3 +404,4 @@ 1.4 39b47ffeb7780407561c0b189c3b3ab497868518 jdk8u60-b07 1.5 e5b93c508212e0db2301cc25f5ada882367d1d9b jdk8u60-b08 1.6 76adee5ad278e33675fdd236179fa83f20de5cc3 jdk8u60-b09 1.7 +ba758e1ffa6960266e5c619b7771ca779ee5d148 jdk8u60-b10
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Apr 01 11:34:59 2015 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Apr 09 22:59:11 2015 -0700 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2012, 2015, 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 @@ -224,7 +224,8 @@ 2.11 DeferredStuckPolicy deferredStuckPolicy; 2.12 if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { 2.13 deferredStuckPolicy = dummyStuckPolicy; 2.14 - } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) { 2.15 + } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE || 2.16 + resultInfo.checkContext.deferredAttrContext().insideOverloadPhase()) { 2.17 deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this); 2.18 } else { 2.19 deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this);
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Wed Apr 01 11:34:59 2015 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Apr 09 22:59:11 2015 -0700 3.3 @@ -265,7 +265,7 @@ 3.4 @Override 3.5 public void visitLambda(JCLambda tree) { 3.6 LambdaTranslationContext localContext = (LambdaTranslationContext)context; 3.7 - MethodSymbol sym = (MethodSymbol)localContext.translatedSym; 3.8 + MethodSymbol sym = localContext.translatedSym; 3.9 MethodType lambdaType = (MethodType) sym.type; 3.10 3.11 { 3.12 @@ -1755,7 +1755,7 @@ 3.13 Map<LambdaSymbolKind, Map<Symbol, Symbol>> translatedSymbols; 3.14 3.15 /** the synthetic symbol for the method hoisting the translated lambda */ 3.16 - Symbol translatedSym; 3.17 + MethodSymbol translatedSym; 3.18 3.19 List<JCVariableDecl> syntheticParams; 3.20 3.21 @@ -1883,7 +1883,7 @@ 3.22 * Translate a symbol of a given kind into something suitable for the 3.23 * synthetic lambda body 3.24 */ 3.25 - Symbol translate(Name name, final Symbol sym, LambdaSymbolKind skind) { 3.26 + Symbol translate(final Symbol sym, LambdaSymbolKind skind) { 3.27 Symbol ret; 3.28 switch (skind) { 3.29 case CAPTURED_THIS: 3.30 @@ -1891,7 +1891,7 @@ 3.31 break; 3.32 case TYPE_VAR: 3.33 // Just erase the type var 3.34 - ret = new VarSymbol(sym.flags(), name, 3.35 + ret = new VarSymbol(sym.flags(), sym.name, 3.36 types.erasure(sym.type), sym.owner); 3.37 3.38 /* this information should also be kept for LVT generation at Gen 3.39 @@ -1900,7 +1900,7 @@ 3.40 ((VarSymbol)ret).pos = ((VarSymbol)sym).pos; 3.41 break; 3.42 case CAPTURED_VAR: 3.43 - ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, name, types.erasure(sym.type), translatedSym) { 3.44 + ret = new VarSymbol(SYNTHETIC | FINAL | PARAMETER, sym.name, types.erasure(sym.type), translatedSym) { 3.45 @Override 3.46 public Symbol baseSymbol() { 3.47 //keep mapping with original captured symbol 3.48 @@ -1909,16 +1909,16 @@ 3.49 }; 3.50 break; 3.51 case LOCAL_VAR: 3.52 - ret = new VarSymbol(sym.flags() & FINAL, name, sym.type, translatedSym); 3.53 + ret = new VarSymbol(sym.flags() & FINAL, sym.name, sym.type, translatedSym); 3.54 ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; 3.55 break; 3.56 case PARAM: 3.57 - ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, name, types.erasure(sym.type), translatedSym); 3.58 + ret = new VarSymbol((sym.flags() & FINAL) | PARAMETER, sym.name, types.erasure(sym.type), translatedSym); 3.59 ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; 3.60 break; 3.61 default: 3.62 - ret = makeSyntheticVar(FINAL, name, types.erasure(sym.type), translatedSym); 3.63 - ((VarSymbol) ret).pos = ((VarSymbol) sym).pos; 3.64 + Assert.error(skind.name()); 3.65 + throw new AssertionError(); 3.66 } 3.67 if (ret != sym) { 3.68 ret.setDeclarationAttributes(sym.getRawAttributes()); 3.69 @@ -1929,27 +1929,8 @@ 3.70 3.71 void addSymbol(Symbol sym, LambdaSymbolKind skind) { 3.72 Map<Symbol, Symbol> transMap = getSymbolMap(skind); 3.73 - Name preferredName; 3.74 - switch (skind) { 3.75 - case CAPTURED_THIS: 3.76 - preferredName = names.fromString("encl$" + transMap.size()); 3.77 - break; 3.78 - case CAPTURED_VAR: 3.79 - preferredName = names.fromString("cap$" + transMap.size()); 3.80 - break; 3.81 - case LOCAL_VAR: 3.82 - preferredName = sym.name; 3.83 - break; 3.84 - case PARAM: 3.85 - preferredName = sym.name; 3.86 - break; 3.87 - case TYPE_VAR: 3.88 - preferredName = sym.name; 3.89 - break; 3.90 - default: throw new AssertionError(); 3.91 - } 3.92 if (!transMap.containsKey(sym)) { 3.93 - transMap.put(sym, translate(preferredName, sym, skind)); 3.94 + transMap.put(sym, translate(sym, skind)); 3.95 } 3.96 } 3.97 3.98 @@ -1997,6 +1978,7 @@ 3.99 3.100 //compute synthetic params 3.101 ListBuffer<JCVariableDecl> params = new ListBuffer<>(); 3.102 + ListBuffer<VarSymbol> parameterSymbols = new ListBuffer<>(); 3.103 3.104 // The signature of the method is augmented with the following 3.105 // synthetic parameters: 3.106 @@ -2005,19 +1987,16 @@ 3.107 // 2) enclosing locals captured by the lambda expression 3.108 for (Symbol thisSym : getSymbolMap(CAPTURED_VAR).values()) { 3.109 params.append(make.VarDef((VarSymbol) thisSym, null)); 3.110 - } 3.111 - if (methodReferenceReceiver != null) { 3.112 - params.append(make.VarDef( 3.113 - make.Modifiers(PARAMETER|FINAL), 3.114 - names.fromString("$rcvr$"), 3.115 - make.Type(methodReferenceReceiver.type), 3.116 - null)); 3.117 + parameterSymbols.append((VarSymbol) thisSym); 3.118 } 3.119 for (Symbol thisSym : getSymbolMap(PARAM).values()) { 3.120 params.append(make.VarDef((VarSymbol) thisSym, null)); 3.121 + parameterSymbols.append((VarSymbol) thisSym); 3.122 } 3.123 syntheticParams = params.toList(); 3.124 3.125 + translatedSym.params = parameterSymbols.toList(); 3.126 + 3.127 // Compute and set the lambda name 3.128 translatedSym.name = isSerializable() 3.129 ? serializedLambdaName()
4.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Wed Apr 01 11:34:59 2015 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Apr 09 22:59:11 2015 -0700 4.3 @@ -2172,7 +2172,11 @@ 4.4 boolean keepLocalVariables = varDebugInfo || 4.5 (var.sym.isExceptionParameter() && var.sym.hasTypeAnnotations()); 4.6 if (!keepLocalVariables) return; 4.7 - if ((var.sym.flags() & Flags.SYNTHETIC) != 0) return; 4.8 + //don't keep synthetic vars, unless they are lambda method parameters 4.9 + boolean ignoredSyntheticVar = (var.sym.flags() & Flags.SYNTHETIC) != 0 && 4.10 + ((var.sym.owner.flags() & Flags.LAMBDA_METHOD) == 0 || 4.11 + (var.sym.flags() & Flags.PARAMETER) == 0); 4.12 + if (ignoredSyntheticVar) return; 4.13 if (varBuffer == null) 4.14 varBuffer = new LocalVar[20]; 4.15 else
5.1 --- a/test/tools/javac/MethodParameters/ClassFileVisitor.java Wed Apr 01 11:34:59 2015 -0700 5.2 +++ b/test/tools/javac/MethodParameters/ClassFileVisitor.java Thu Apr 09 22:59:11 2015 -0700 5.3 @@ -147,6 +147,7 @@ 5.4 public int mAttrs; 5.5 public int mNumParams; 5.6 public boolean mSynthetic; 5.7 + public boolean mIsLambda; 5.8 public boolean mIsConstructor; 5.9 public boolean mIsClinit; 5.10 public boolean mIsBridge; 5.11 @@ -165,6 +166,7 @@ 5.12 mIsClinit = mName.equals("<clinit>"); 5.13 prefix = cname + "." + mName + "() - "; 5.14 mIsBridge = method.access_flags.is(AccessFlags.ACC_BRIDGE); 5.15 + mIsLambda = mSynthetic && mName.startsWith("lambda$"); 5.16 5.17 if (mIsClinit) { 5.18 sb = new StringBuilder(); // Discard output 5.19 @@ -225,7 +227,7 @@ 5.20 5.21 // IMPL: Whether MethodParameters attributes will be generated 5.22 // for some synthetics is unresolved. For now, assume no. 5.23 - if (mSynthetic) { 5.24 + if (mSynthetic && !mIsLambda) { 5.25 warn(prefix + "synthetic has MethodParameter attribute"); 5.26 } 5.27 5.28 @@ -349,10 +351,12 @@ 5.29 } else if (isEnum && mNumParams == 1 && index == 0 && mName.equals("valueOf")) { 5.30 expect = "name"; 5.31 allowMandated = true; 5.32 - } else if (mIsBridge) { 5.33 + } else if (mIsBridge || mIsLambda) { 5.34 allowSynthetic = true; 5.35 /* you can't expect an special name for bridges' parameters. 5.36 - * The name of the original parameters are now copied. 5.37 + * The name of the original parameters are now copied. Likewise 5.38 + * for a method encoding the lambda expression, names are derived 5.39 + * from source lambda's parameters and captured enclosing locals. 5.40 */ 5.41 expect = null; 5.42 }
6.1 --- a/test/tools/javac/MethodParameters/LambdaTest.java Wed Apr 01 11:34:59 2015 -0700 6.2 +++ b/test/tools/javac/MethodParameters/LambdaTest.java Thu Apr 09 22:59:11 2015 -0700 6.3 @@ -1,5 +1,5 @@ 6.4 /* 6.5 - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 6.6 + * Copyright (c) 2013, 2015 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 @@ -23,7 +23,7 @@ 6.11 6.12 /* 6.13 * @test 6.14 - * @bug 8006582 6.15 + * @bug 8006582 8037546 6.16 * @summary javac should generate method parameters correctly. 6.17 * @build Tester 6.18 * @compile -parameters LambdaTest.java 6.19 @@ -31,8 +31,8 @@ 6.20 */ 6.21 6.22 /** 6.23 - * Parameter names are not recorded for lambdas. This test verifies 6.24 - * that there are no MethodParameters attribute for lambdas. 6.25 + * Post https://bugs.openjdk.java.net/browse/JDK-8037546, this test verifies 6.26 + * that MethodParameters attribute for lambdas are emitted properly. 6.27 */ 6.28 class LambdaTest { 6.29
7.1 --- a/test/tools/javac/MethodParameters/LambdaTest.out Wed Apr 01 11:34:59 2015 -0700 7.2 +++ b/test/tools/javac/MethodParameters/LambdaTest.out Thu Apr 09 22:59:11 2015 -0700 7.3 @@ -1,7 +1,7 @@ 7.4 class LambdaTest -- 7.5 LambdaTest.<init>() 7.6 LambdaTest.foo(i) 7.7 -LambdaTest.lambda$static$1(arg0)/*synthetic*/ 7.8 -LambdaTest.lambda$null$0(arg0, arg1)/*synthetic*/ 7.9 +LambdaTest.lambda$static$1(x1/*synthetic*/)/*synthetic*/ 7.10 +LambdaTest.lambda$null$0(final x1/*synthetic*/, x2/*synthetic*/)/*synthetic*/ 7.11 static interface LambdaTest$I -- inner 7.12 LambdaTest$I.m(x)
8.1 --- a/test/tools/javac/MethodParameters/ReflectionVisitor.java Wed Apr 01 11:34:59 2015 -0700 8.2 +++ b/test/tools/javac/MethodParameters/ReflectionVisitor.java Thu Apr 09 22:59:11 2015 -0700 8.3 @@ -277,7 +277,7 @@ 8.4 param = "final " + param; 8.5 } 8.6 sb.append(sep).append(param); 8.7 - if (!m.isBridge() && !expect.equals(param)) { 8.8 + if (!m.isBridge() && !m.getName().startsWith("lambda$") && !expect.equals(param)) { 8.9 error(prefix + "param[" + i + "]='" 8.10 + param + "' expected '" + expect + "'"); 8.11 break;
9.1 --- a/test/tools/javac/lambda/8016177/T8016177g.java Wed Apr 01 11:34:59 2015 -0700 9.2 +++ b/test/tools/javac/lambda/8016177/T8016177g.java Thu Apr 09 22:59:11 2015 -0700 9.3 @@ -1,6 +1,6 @@ 9.4 /* 9.5 * @test /nodynamiccopyright/ 9.6 - * @bug 8016081 8016178 9.7 + * @bug 8016081 8016178 8069545 9.8 * @summary structural most specific and stuckness 9.9 * @compile/fail/ref=T8016177g.out -XDrawDiagnostics T8016177g.java 9.10 */
10.1 --- a/test/tools/javac/lambda/8016177/T8016177g.out Wed Apr 01 11:34:59 2015 -0700 10.2 +++ b/test/tools/javac/lambda/8016177/T8016177g.out Thu Apr 09 22:59:11 2015 -0700 10.3 @@ -1,2 +1,3 @@ 10.4 -T8016177g.java:35:20: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int) 10.5 -1 error 10.6 +T8016177g.java:34:14: compiler.err.cant.apply.symbol: kindname.method, print, java.lang.String, Test.Person, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: Test.Person, java.lang.String,java.lang.Object)) 10.7 +T8016177g.java:35:20: compiler.err.cant.apply.symbol: kindname.method, abs, int, java.lang.Double, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , R, int)) 10.8 +2 errors
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/lambda/8068399/T8068399.java Thu Apr 09 22:59:11 2015 -0700 11.3 @@ -0,0 +1,119 @@ 11.4 +/* 11.5 + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. Oracle designates this 11.11 + * particular file as subject to the "Classpath" exception as provided 11.12 + * by Oracle in the LICENSE file that accompanied this code. 11.13 + * 11.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.17 + * version 2 for more details (a copy is included in the LICENSE file that 11.18 + * accompanied this code). 11.19 + * 11.20 + * You should have received a copy of the GNU General Public License version 11.21 + * 2 along with this work; if not, write to the Free Software Foundation, 11.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.23 + * 11.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.25 + * or visit www.oracle.com if you need additional information or have any 11.26 + * questions. 11.27 + */ 11.28 +/* 11.29 + * @test 11.30 + * @bug 8068399 11.31 + * @summary structural most specific and stuckness 11.32 + */ 11.33 + 11.34 +import java.util.function.Function; 11.35 +import java.util.stream.IntStream; 11.36 +import java.util.stream.Stream; 11.37 + 11.38 +public class T8068399 { 11.39 + 11.40 + public static class Spectrum { 11.41 + public double[] getEnergy() { 11.42 + return new double[0]; 11.43 + } 11.44 + } 11.45 + 11.46 + protected Spectrum spectrum; 11.47 + 11.48 + public static class Ref<T> { 11.49 + 11.50 + T value; 11.51 + 11.52 + public Ref() { 11.53 + } 11.54 + 11.55 + public Ref(T value) { 11.56 + this.value = value; 11.57 + } 11.58 + 11.59 + public boolean isNull() { 11.60 + return value == null; 11.61 + } 11.62 + 11.63 + public T get() { 11.64 + return value; 11.65 + } 11.66 + 11.67 + public void set(T value) { 11.68 + this.value = value; 11.69 + } 11.70 + } 11.71 + 11.72 + public static <T>T maxKey(Stream<T> stream, Function<T, Double> function) { 11.73 + Ref<Double> max = new Ref<>(); 11.74 + Ref<T> index = new Ref<>(); 11.75 + stream.forEach(v -> { 11.76 + Double value = function.apply(v); 11.77 + 11.78 + if (max.isNull() || value > max.get()) { 11.79 + max.set(value); 11.80 + index.set(v); 11.81 + } 11.82 + }); 11.83 + 11.84 + return index.get(); 11.85 + } 11.86 + 11.87 + public static int interpolate(int x, int x0, int x1, int y0, int y1) { 11.88 + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); 11.89 + } 11.90 + 11.91 + public static double interpolate(double x, double x0, double x1, double y0, double y1) { 11.92 + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); 11.93 + } 11.94 + 11.95 + protected int getXByFrequency(double frequency) { 11.96 + return (int) Math.round(interpolate(frequency, 11.97 + getMinSpectrumCoord(), 11.98 + getMaxSpectrumCoord(), 11.99 + 0, getWidth())); 11.100 + } 11.101 + 11.102 + private int getWidth() { 11.103 + return 0; 11.104 + } 11.105 + 11.106 + private double getMaxSpectrumCoord() { 11.107 + return 0; 11.108 + } 11.109 + 11.110 + private double getMinSpectrumCoord() { 11.111 + return 0; 11.112 + } 11.113 + 11.114 + void foo() { 11.115 + int maxBpmIndex = 0; 11.116 + int xcur = getXByFrequency(maxKey(IntStream.range(0, maxBpmIndex).boxed(), 11.117 + i -> Math.abs(spectrum.getEnergy()[i]))); 11.118 + } 11.119 + 11.120 + public static void main(String [] args) { 11.121 + } 11.122 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/lambda/8068430/T8068430.java Thu Apr 09 22:59:11 2015 -0700 12.3 @@ -0,0 +1,46 @@ 12.4 +/* 12.5 + * Copyright (c) 2015, 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. Oracle designates this 12.11 + * particular file as subject to the "Classpath" exception as provided 12.12 + * by Oracle in the LICENSE file that accompanied this code. 12.13 + * 12.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.17 + * version 2 for more details (a copy is included in the LICENSE file that 12.18 + * accompanied this code). 12.19 + * 12.20 + * You should have received a copy of the GNU General Public License version 12.21 + * 2 along with this work; if not, write to the Free Software Foundation, 12.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.23 + * 12.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.25 + * or visit www.oracle.com if you need additional information or have any 12.26 + * questions. 12.27 + */ 12.28 + 12.29 +/* 12.30 + * @test 12.31 + * @bug 8068430 12.32 + * @summary structural most specific and stuckness 12.33 + */ 12.34 + 12.35 +import java.util.HashMap; 12.36 +import java.util.Map; 12.37 + 12.38 +public class T8068430 { 12.39 + public static void main(String[] args) { 12.40 + Map<Integer, String> mp = new HashMap<>(); 12.41 + mp.put(1, "a"); 12.42 + mp.put(2, "b"); 12.43 + mp.put(3, "c"); 12.44 + mp.put(4, "d"); 12.45 + System.out.println(mp.entrySet().stream().reduce(0, 12.46 + (i, e) -> i + e.getKey(), 12.47 + (i1, i2) -> i1 + i2)); 12.48 + } 12.49 +} 12.50 \ No newline at end of file
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/lambda/8071432/T8071432.java Thu Apr 09 22:59:11 2015 -0700 13.3 @@ -0,0 +1,50 @@ 13.4 +/* 13.5 + * @test /nodynamiccopyright/ 13.6 + * @bug 8071432 13.7 + * @summary structural most specific and stuckness 13.8 + * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java 13.9 + */ 13.10 + 13.11 +import java.util.Arrays; 13.12 +import java.util.Collection; 13.13 + 13.14 +class T8071432 { 13.15 + 13.16 + static class Point { 13.17 + 13.18 + private double x, y; 13.19 + 13.20 + public Point(double x, double y) { 13.21 + this.x = x; 13.22 + this.y = y; 13.23 + } 13.24 + 13.25 + public double getX() { 13.26 + return x; 13.27 + } 13.28 + 13.29 + public double getY() { 13.30 + return y; 13.31 + } 13.32 + 13.33 + public double distance(Point p) { 13.34 + return Math.sqrt((this.x - p.x) * (this.x - p.x) + 13.35 + (this.y - p.y) * (this.y - p.y)); 13.36 + } 13.37 + 13.38 + public double distance() { 13.39 + return Math.sqrt(this.x * this.x + this.y * this.y); 13.40 + } 13.41 + 13.42 + public String toString() { 13.43 + return "(" + x + ":" + y + ")"; 13.44 + } 13.45 + } 13.46 + 13.47 + public static void main(String[] args) { 13.48 + Collection<Point> c = Arrays.asList(new Point(1.0, 0.1)); 13.49 + System.out.println("------- 1 ---------------"); 13.50 + System.out.println(c.stream().reduce(0.0, 13.51 + (s, p) -> s += p.distance(), (d1, d2) -> 0)); 13.52 + } 13.53 +}
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/lambda/8071432/T8071432.out Thu Apr 09 22:59:11 2015 -0700 14.3 @@ -0,0 +1,3 @@ 14.4 +T8071432.java:47:45: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double))) 14.5 +T8071432.java:47:27: compiler.err.cant.apply.symbol: kindname.method, println, java.lang.Object, <any>, kindname.class, java.io.PrintStream, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double)))) 14.6 +2 errors
15.1 --- a/test/tools/javac/lambda/LocalVariableTable.java Wed Apr 01 11:34:59 2015 -0700 15.2 +++ b/test/tools/javac/lambda/LocalVariableTable.java Thu Apr 09 22:59:11 2015 -0700 15.3 @@ -23,7 +23,7 @@ 15.4 15.5 /* 15.6 * @test 15.7 - * @bug 8025998 8026749 15.8 + * @bug 8025998 8026749 8054220 8058227 15.9 * @summary Missing LV table in lambda bodies 15.10 * @compile -g LocalVariableTable.java 15.11 * @run main LocalVariableTable 15.12 @@ -183,7 +183,7 @@ 15.13 Run1 r = (a) -> { int x = a; }; 15.14 } 15.15 15.16 - @Expect({ "a", "x" }) 15.17 + @Expect({ "a", "x", "v" }) 15.18 static class Lambda_Args1_Local1_Captured1 { 15.19 void m() { 15.20 int v = 0; 15.21 @@ -191,7 +191,7 @@ 15.22 } 15.23 } 15.24 15.25 - @Expect({ "a1", "a2", "x1", "x2", "this" }) 15.26 + @Expect({ "a1", "a2", "x1", "x2", "this", "v1", "v2" }) 15.27 static class Lambda_Args2_Local2_Captured2_this { 15.28 int v; 15.29 void m() { 15.30 @@ -204,7 +204,7 @@ 15.31 } 15.32 } 15.33 15.34 - @Expect({ "e" }) 15.35 + @Expect({ "e", "c" }) 15.36 static class Lambda_Try_Catch { 15.37 private static Runnable asUncheckedRunnable(Closeable c) { 15.38 return () -> {