changeset 934:1623ce0ec047

Types.findSAM throws NPE when target type of SAM conversion is an interface inheriting non-overriding members.
author mcimadamore
date Mon, 07 Mar 2011 13:54:51 +0000
parents c80ead80fcfd
children cb9074345db0
files src/share/classes/com/sun/tools/javac/code/Types.java test/tools/javac/lambda/BadConv03.java test/tools/javac/lambda/BadConv03.out
diffstat 3 files changed, 45 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Mar 07 11:50:39 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Mar 07 13:54:51 2011 +0000
@@ -466,9 +466,10 @@
                 Symbol impl = msym.implementation(site.tsym, this, false);
                 if (impl == null || (impl.flags() & ABSTRACT) != 0) {
                     count++;
+                    Type mtype = memberType(site, msym);
                     if (buf.isEmpty() ||
                             (msym.name == buf.first().name &&
-                            overrideEquivalent(impl.type, buf.first().type))) {
+                            overrideEquivalent(mtype, memberType(site, buf.first())))) {
                         buf.append(e.sym);
                     }
                 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/BadConv03.java	Mon Mar 07 13:54:51 2011 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 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
+ * @summary NPE while checking if subinterface is a SAM type
+ * @compile/fail/ref=BadConv03.out -XDrawDiagnostics BadConv03.java
+ */
+
+class BadConv03 {
+
+    interface A {
+        void a();
+    }
+
+    interface B extends A { //not a SAM (2 non-override equivalent abstracts!)
+        void a(int i);
+    }
+
+    B b = #{ };
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/lambda/BadConv03.out	Mon Mar 07 13:54:51 2011 +0000
@@ -0,0 +1,2 @@
+BadConv03.java:40:11: compiler.err.invalid.target.type.for.lambda.conv.1: BadConv03.B, (compiler.misc.multiple.targets.for.lambda.conv: null, kindname.interface, BadConv03.B)
+1 error