8007535: Compiler crashes on @FunctionalInterface used on interface with two inherited methods with same signatures
Summary: Bad check in Types.interfaceCandidates
Reviewed-by: jjg
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Feb 15 16:29:58 2013 +0000
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Fri Feb 15 16:30:31 2013 +0000
@@ -2606,16 +2606,17 @@
candidates = candidates.prepend((MethodSymbol)s);
}
}
- return prune(candidates, ownerComparator);
+ return prune(candidates);
}
- public List<MethodSymbol> prune(List<MethodSymbol> methods, Comparator<MethodSymbol> cmp) {
+ public List<MethodSymbol> prune(List<MethodSymbol> methods) {
ListBuffer<MethodSymbol> methodsMin = ListBuffer.lb();
for (MethodSymbol m1 : methods) {
boolean isMin_m1 = true;
for (MethodSymbol m2 : methods) {
if (m1 == m2) continue;
- if (cmp.compare(m2, m1) < 0) {
+ if (m2.owner != m1.owner &&
+ asSuper(m2.owner.type, m1.owner) != null) {
isMin_m1 = false;
break;
}
@@ -2625,12 +2626,6 @@
}
return methodsMin.toList();
}
-
- Comparator<MethodSymbol> ownerComparator = new Comparator<MethodSymbol>() {
- public int compare(MethodSymbol s1, MethodSymbol s2) {
- return s1.owner.isSubClass(s2.owner, Types.this) ? -1 : 1;
- }
- };
// where
private class MethodFilter implements Filter<Symbol> {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/FunctionalInterfaceAnno02.java Fri Feb 15 16:30:31 2013 +0000
@@ -0,0 +1,38 @@
+/*
+ * 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 8007535
+ * @summary Compiler crashes on FunctionalInterface used on interface with two inherited methods with same signatures
+ * @compile FunctionalInterfaceAnno02.java
+ */
+class FunctionalInterfaceAnno02 {
+ interface Foo<T, N extends Number> {
+ void m(T arg);
+ void m(N arg);
+ }
+
+ @FunctionalInterface
+ interface Baz extends Foo<Integer, Integer> { }
+}