Merge jdk8u40-b12

Wed, 22 Oct 2014 12:30:25 -0700

author
lana
date
Wed, 22 Oct 2014 12:30:25 -0700
changeset 2593
e7560bceb36a
parent 2589
8c4a9603598f
parent 2592
c058b97ecb87
child 2594
93cc96153390
child 2595
1cf5a53613ae

Merge

     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Oct 22 11:18:28 2014 -0700
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java	Wed Oct 22 12:30:25 2014 -0700
     1.3 @@ -247,7 +247,7 @@
     1.4                      return !env.info.scope.includes(sym) &&
     1.5                             sym.owner.kind == MTH;
     1.6                  }
     1.7 -            }.analyzeTree(env);
     1.8 +            }.analyzeTree(env, that);
     1.9              LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer();
    1.10              flowAnalyzer.analyzeTree(env, that, make);
    1.11              return flowAnalyzer.inferredThrownTypes;
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Oct 22 11:18:28 2014 -0700
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java	Wed Oct 22 12:30:25 2014 -0700
     2.3 @@ -846,6 +846,10 @@
     2.4                  if (rcvr == null) return null;
     2.5                  JCExpression rcvrExpr = make.Ident(rcvr);
     2.6                  Type rcvrType = tree.sym.enclClass().type;
     2.7 +                if (rcvrType == syms.arrayClass.type) {
     2.8 +                    // Map the receiver type to the actually type, not just "array"
     2.9 +                    rcvrType = tree.getQualifierExpression().type;
    2.10 +                }
    2.11                  if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) {
    2.12                      rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType);
    2.13                  }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/tools/javac/flow/T8042741/LambdaArgumentsTest.java	Wed Oct 22 12:30:25 2014 -0700
     3.3 @@ -0,0 +1,44 @@
     3.4 +/*
     3.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +
    3.27 +/* @test
    3.28 + * @bug 8054210
    3.29 + * @summary NullPointerException when compiling specific code
    3.30 + * @compile LambdaArgumentsTest.java
    3.31 + */
    3.32 +
    3.33 +public class LambdaArgumentsTest  {
    3.34 +    interface Thrower<E extends Exception> { void apply() throws E; }
    3.35 +    interface Consumer<E> { void take(E arg); }
    3.36 +
    3.37 +    <E extends Exception>
    3.38 +    void m1(Thrower<E> a1, Consumer<E> a2) {}
    3.39 +
    3.40 +    <E extends Exception>
    3.41 +    void m2(Thrower<E> a1, Consumer<RuntimeException> a2) {}
    3.42 +
    3.43 +    void test() {
    3.44 +        m1(() -> {}, e -> {});
    3.45 +        m2(() -> {}, (RuntimeException e) -> {});
    3.46 +    }
    3.47 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/tools/javac/lambda/MethodReferenceArrayClone.java	Wed Oct 22 12:30:25 2014 -0700
     4.3 @@ -0,0 +1,67 @@
     4.4 +/*
     4.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +
    4.27 +/*
    4.28 + * @test
    4.29 + * @bug 8056051
    4.30 + * @summary int[]::clone causes "java.lang.NoClassDefFoundError: Array"
    4.31 + * @run main MethodReferenceArrayClone
    4.32 + */
    4.33 +
    4.34 +import java.util.Arrays;
    4.35 +import java.util.function.Function;
    4.36 +import java.util.function.Supplier;
    4.37 +
    4.38 +public class MethodReferenceArrayClone {
    4.39 +    public static void main(String[] args) {
    4.40 +        int[] intArgs = new int[] {1, 2, 3, 4, 5};
    4.41 +        checkInt("int[]::clone", int[]::clone, intArgs);
    4.42 +        checkInt("a -> a.clone()", a -> a.clone(), intArgs);
    4.43 +        checkInt("intArgs::clone", intArgs::clone, intArgs);
    4.44 +
    4.45 +        String[] stringArgs = new String[] {"hi", "de", "ho"};
    4.46 +        checkString("String[]::clone", String[]::clone, stringArgs);
    4.47 +        checkString("a -> a.clone()", a -> a.clone(), stringArgs);
    4.48 +        checkString("args::clone", stringArgs::clone, stringArgs);
    4.49 +    }
    4.50 +
    4.51 +    private static void checkInt(String label, Supplier<int[]> s, int[] expected) {
    4.52 +        if (!Arrays.equals(s.get(), expected)) {
    4.53 +            throw new RuntimeException("Unexpected value " + label + ": " + Arrays.toString(s.get()));
    4.54 +        }
    4.55 +    }
    4.56 +
    4.57 +    private static void checkInt(String label, Function<int[], int[]> f, int[] a) {
    4.58 +        checkInt(label, () -> f.apply(a), a);
    4.59 +    }
    4.60 +
    4.61 +    private static void checkString(String label, Supplier<String[]> s, String[] expected) {
    4.62 +        if (!Arrays.equals(s.get(), expected)) {
    4.63 +            throw new RuntimeException("Unexpected value " + label + ": " + Arrays.toString(s.get()));
    4.64 +        }
    4.65 +    }
    4.66 +
    4.67 +    private static void checkString(String label, Function<String[], String[]> f, String[] a) {
    4.68 +        checkString(label, () -> f.apply(a), a);
    4.69 +    }
    4.70 +}

mercurial