# HG changeset patch # User rfield # Date 1382566595 25200 # Node ID 9792667abbf2eeaa99ce418efe49b3cbf060a7c5 # Parent 0372edc9a995fb1bdea1954e97f90f86755c5425 8025868: Several lang/LMBD JCK tests fail with java.lang.BootstrapMethodError Summary: Wildcard marker interfaces can cause duplicate implemented interfaces in generated lambda class Reviewed-by: briangoetz diff -r 0372edc9a995 -r 9792667abbf2 jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java --- a/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Wed Oct 23 14:32:41 2013 -0700 +++ b/jdk/src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java Wed Oct 23 15:16:35 2013 -0700 @@ -33,8 +33,10 @@ import java.lang.reflect.Constructor; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.LinkedHashSet; import java.util.concurrent.atomic.AtomicInteger; import java.util.PropertyPermission; +import java.util.Set; import static jdk.internal.org.objectweb.asm.Opcodes.*; @@ -226,11 +228,20 @@ * is not found */ private Class spinInnerClass() throws LambdaConversionException { - String[] interfaces = new String[markerInterfaces.length + 1]; - interfaces[0] = samBase.getName().replace('.', '/'); - for (int i=0; i itfs = new LinkedHashSet<>(markerInterfaces.length + 1); + itfs.add(samIntf); + for (int i = 0; i < markerInterfaces.length; i++) { + itfs.add(markerInterfaces[i].getName().replace('.', '/')); + } + interfaces = itfs.toArray(new String[itfs.size()]); } + cw.visit(CLASSFILE_VERSION, ACC_SUPER + ACC_FINAL + ACC_SYNTHETIC, lambdaClassName, null, JAVA_LANG_OBJECT, interfaces); diff -r 0372edc9a995 -r 9792667abbf2 jdk/test/java/lang/invoke/lambda/DupIntf.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/lang/invoke/lambda/DupIntf.java Wed Oct 23 15:16:35 2013 -0700 @@ -0,0 +1,42 @@ +/* + * 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 8025868 + * @summary Lambda class can be generated with duplicate interfaces (ClassFormatError) + * @run main DupIntf + */ + +interface SAM { + P1 m(); +} + +interface Other { } + +public class DupIntf { + public static void main(String argv[]) { + SAM sam = (SAM & Other) () -> "Pass."; + System.out.println(sam.m()); + } +}