Mercurial > hg > openjdk > lambda > langtools
changeset 2239:8af11dc40730
8020804: javac crashes when speculative attribution infers intersection type with array component
author | mcimadamore |
---|---|
date | Thu, 18 Jul 2013 12:38:17 +0100 |
parents | a6e792b06adc |
children | 6052d5d0de46 |
files | src/share/classes/com/sun/tools/javac/code/Types.java src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/comp/Infer.java test/tools/javac/lambda/8020804/T8020804.java |
diffstat | 4 files changed, 54 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jul 16 17:29:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Thu Jul 18 12:38:17 2013 +0100 @@ -620,7 +620,9 @@ * (ii) perform functional interface bridge calculation. */ public ClassSymbol makeFunctionalInterfaceClass(Env<AttrContext> env, Name name, List<Type> targets, long cflags) { - Assert.check(targets.nonEmpty() && isFunctionalInterface(targets.head)); + if (targets.isEmpty() || !isFunctionalInterface(targets.head)) { + return null; + } Symbol descSym = findDescriptorSymbol(targets.head.tsym); Type descType = findDescriptorType(targets.head); ClassSymbol csym = new ClassSymbol(cflags, name, env.enclClass.sym.outermostClass());
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Jul 16 17:29:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jul 18 12:38:17 2013 +0100 @@ -2961,7 +2961,9 @@ //check that functional interface class is well-formed ClassSymbol csym = types.makeFunctionalInterfaceClass(env, names.empty, List.of(fExpr.targets.head), ABSTRACT); - chk.checkImplementations(env.tree, csym, csym); + if (csym != null) { + chk.checkImplementations(env.tree, csym, csym); + } } } }
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Jul 16 17:29:54 2013 +0100 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Jul 18 12:38:17 2013 +0100 @@ -1207,7 +1207,8 @@ CAPTURED(InferenceBound.UPPER) { @Override public boolean accepts(UndetVar t, InferenceContext inferenceContext) { - return !inferenceContext.free(t.getBounds(InferenceBound.UPPER, InferenceBound.LOWER)); + return t.isCaptured() && + !inferenceContext.free(t.getBounds(InferenceBound.UPPER, InferenceBound.LOWER)); } @Override
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/lambda/8020804/T8020804.java Thu Jul 18 12:38:17 2013 +0100 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013, 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. + * + * 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 8020804 + * @summary javac crashes when speculative attribution infers intersection type with array component + * @compile T8020804.java + */ + +import java.util.*; + +class T8020804 { + interface Supplier<D> { + D make(); + } + + void m(Object o) { } + void m(char[] c) { } + + <C extends Collection<?>> C g(Supplier<C> sc) { return null; } + + void test() { + m(g(LinkedList<Double>::new)); + } +}