# HG changeset patch # User duke # Date 1499278780 -7200 # Node ID e109824f8bb94db341b1810d5ed4987bb3e8ca99 # Parent bf992bd35aadbf29742db45486c85cae0ae504a9# Parent 3f8aa7cda847ec3644802f18869ad112eb13f97d Merge diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/.hgtags --- a/langtools/.hgtags Wed Jul 05 20:19:33 2017 +0200 +++ b/langtools/.hgtags Wed Jul 05 20:19:40 2017 +0200 @@ -292,3 +292,4 @@ 230c139552501e612dd0d4423ac30f94c1201c0d jdk9-b47 5b102fc29edf8b7eee7df208d8a8bba0e0a52f3a jdk9-b48 15c79f28e30a1be561abe0d67674232ad5034d32 jdk9-b49 +1ccb6ef2f40bf9961b27adac390a6fc5181aa1fc jdk9-b50 diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Jul 05 20:19:33 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Jul 05 20:19:40 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -236,7 +236,8 @@ DeferredStuckPolicy deferredStuckPolicy; if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) { deferredStuckPolicy = dummyStuckPolicy; - } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) { + } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE || + resultInfo.checkContext.deferredAttrContext().insideOverloadPhase()) { deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this); } else { deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this); diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JavacMessages.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JavacMessages.java Wed Jul 05 20:19:33 2017 +0200 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JavacMessages.java Wed Jul 05 20:19:40 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ private Map>> bundleCache; - private List bundleNames; + private List bundleHelpers; private Locale currentLocale; private List currentBundles; @@ -91,7 +91,7 @@ * @param bundleName the name to identify the resource bundle of localized messages. */ public JavacMessages(String bundleName, Locale locale) throws MissingResourceException { - bundleNames = List.nil(); + bundleHelpers = List.nil(); bundleCache = new HashMap<>(); add(bundleName); setCurrentLocale(locale); @@ -101,8 +101,13 @@ this(defaultBundleName); } + @Override public void add(String bundleName) throws MissingResourceException { - bundleNames = bundleNames.prepend(bundleName); + add(locale -> ResourceBundle.getBundle(bundleName, locale)); + } + + public void add(ResourceBundleHelper ma) { + bundleHelpers = bundleHelpers.prepend(ma); if (!bundleCache.isEmpty()) bundleCache.clear(); currentBundles = null; @@ -115,12 +120,13 @@ List bundleList = bundles == null ? null : bundles.get(); if (bundleList == null) { bundleList = List.nil(); - for (String bundleName : bundleNames) { + for (ResourceBundleHelper helper : bundleHelpers) { try { - ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale); + ResourceBundle rb = helper.getResourceBundle(locale); bundleList = bundleList.prepend(rb); } catch (MissingResourceException e) { - throw new InternalError("Cannot find javac resource bundle for locale " + locale); + throw new InternalError("Cannot find requested resource bundle for locale " + + locale, e); } } bundleCache.put(locale, new SoftReference<>(bundleList)); @@ -134,6 +140,7 @@ return getLocalizedString(currentLocale, key, args); } + @Override public String getLocalizedString(Locale l, String key, Object... args) { if (l == null) l = getCurrentLocale(); @@ -146,8 +153,7 @@ * easy access to simple localized strings. */ - private static final String defaultBundleName = - "com.sun.tools.javac.resources.compiler"; + private static final String defaultBundleName = "com.sun.tools.javac.resources.compiler"; private static ResourceBundle defaultBundle; private static JavacMessages defaultMessages; @@ -198,4 +204,17 @@ } return MessageFormat.format(msg, args); } + + /** + * This provides a way for the JavacMessager to retrieve a + * ResourceBundle from another module such as jdk.javadoc. + */ + public interface ResourceBundleHelper { + /** + * Gets the ResourceBundle. + * @param locale the requested bundle's locale + * @return ResourceBundle + */ + ResourceBundle getResourceBundle(Locale locale); + } } diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Messager.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Messager.java Wed Jul 05 20:19:33 2017 +0200 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Messager.java Wed Jul 05 20:19:40 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ import java.io.PrintWriter; import java.util.Locale; +import java.util.ResourceBundle; import com.sun.javadoc.*; import com.sun.tools.javac.util.Context; @@ -126,9 +127,11 @@ PrintWriter noticeWriter) { super(context, errWriter, warnWriter, noticeWriter); messages = JavacMessages.instance(context); - messages.add("com.sun.tools.javadoc.resources.javadoc"); + messages.add(locale -> ResourceBundle.getBundle("com.sun.tools.javadoc.resources.javadoc", + locale)); javadocDiags = new JCDiagnostic.Factory(messages, "javadoc"); this.programName = programName; + } public void setLocale(Locale locale) { diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/test/tools/javac/lambda/8016177/T8016177g.java --- a/langtools/test/tools/javac/lambda/8016177/T8016177g.java Wed Jul 05 20:19:33 2017 +0200 +++ b/langtools/test/tools/javac/lambda/8016177/T8016177g.java Wed Jul 05 20:19:40 2017 +0200 @@ -1,6 +1,6 @@ /* * @test /nodynamiccopyright/ - * @bug 8016081 8016178 + * @bug 8016081 8016178 8069545 * @summary structural most specific and stuckness * @compile/fail/ref=T8016177g.out -XDrawDiagnostics T8016177g.java */ diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/test/tools/javac/lambda/8016177/T8016177g.out --- a/langtools/test/tools/javac/lambda/8016177/T8016177g.out Wed Jul 05 20:19:33 2017 +0200 +++ b/langtools/test/tools/javac/lambda/8016177/T8016177g.out Wed Jul 05 20:19:40 2017 +0200 @@ -1,2 +1,3 @@ -T8016177g.java:35:20: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int) -1 error +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)) +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)) +2 errors diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/test/tools/javac/lambda/8068399/T8068399.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/8068399/T8068399.java Wed Jul 05 20:19:40 2017 +0200 @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8068399 + * @summary structural most specific and stuckness + */ + +import java.util.function.Function; +import java.util.stream.IntStream; +import java.util.stream.Stream; + +public class T8068399 { + + public static class Spectrum { + public double[] getEnergy() { + return new double[0]; + } + } + + protected Spectrum spectrum; + + public static class Ref { + + T value; + + public Ref() { + } + + public Ref(T value) { + this.value = value; + } + + public boolean isNull() { + return value == null; + } + + public T get() { + return value; + } + + public void set(T value) { + this.value = value; + } + } + + public static T maxKey(Stream stream, Function function) { + Ref max = new Ref<>(); + Ref index = new Ref<>(); + stream.forEach(v -> { + Double value = function.apply(v); + + if (max.isNull() || value > max.get()) { + max.set(value); + index.set(v); + } + }); + + return index.get(); + } + + public static int interpolate(int x, int x0, int x1, int y0, int y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + + public static double interpolate(double x, double x0, double x1, double y0, double y1) { + return y0 + (x - x0) * (y1 - y0) / (x1 - x0); + } + + protected int getXByFrequency(double frequency) { + return (int) Math.round(interpolate(frequency, + getMinSpectrumCoord(), + getMaxSpectrumCoord(), + 0, getWidth())); + } + + private int getWidth() { + return 0; + } + + private double getMaxSpectrumCoord() { + return 0; + } + + private double getMinSpectrumCoord() { + return 0; + } + + void foo() { + int maxBpmIndex = 0; + int xcur = getXByFrequency(maxKey(IntStream.range(0, maxBpmIndex).boxed(), + i -> Math.abs(spectrum.getEnergy()[i]))); + } + + public static void main(String [] args) { + } +} diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/test/tools/javac/lambda/8068430/T8068430.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/8068430/T8068430.java Wed Jul 05 20:19:40 2017 +0200 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8068430 + * @summary structural most specific and stuckness + */ + +import java.util.HashMap; +import java.util.Map; + +public class T8068430 { + public static void main(String[] args) { + Map mp = new HashMap<>(); + mp.put(1, "a"); + mp.put(2, "b"); + mp.put(3, "c"); + mp.put(4, "d"); + System.out.println(mp.entrySet().stream().reduce(0, + (i, e) -> i + e.getKey(), + (i1, i2) -> i1 + i2)); + } +} \ No newline at end of file diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/test/tools/javac/lambda/8071432/T8071432.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/8071432/T8071432.java Wed Jul 05 20:19:40 2017 +0200 @@ -0,0 +1,50 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8071432 + * @summary structural most specific and stuckness + * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java + */ + +import java.util.Arrays; +import java.util.Collection; + +class T8071432 { + + static class Point { + + private double x, y; + + public Point(double x, double y) { + this.x = x; + this.y = y; + } + + public double getX() { + return x; + } + + public double getY() { + return y; + } + + public double distance(Point p) { + return Math.sqrt((this.x - p.x) * (this.x - p.x) + + (this.y - p.y) * (this.y - p.y)); + } + + public double distance() { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + + public String toString() { + return "(" + x + ":" + y + ")"; + } + } + + public static void main(String[] args) { + Collection c = Arrays.asList(new Point(1.0, 0.1)); + System.out.println("------- 1 ---------------"); + System.out.println(c.stream().reduce(0.0, + (s, p) -> s += p.distance(), (d1, d2) -> 0)); + } +} diff -r 3f8aa7cda847 -r e109824f8bb9 langtools/test/tools/javac/lambda/8071432/T8071432.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/8071432/T8071432.out Wed Jul 05 20:19:40 2017 +0200 @@ -0,0 +1,3 @@ +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))) +T8071432.java:47:27: compiler.err.cant.apply.symbol: kindname.method, println, java.lang.Object, , 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)))) +2 errors