rfield@2528: /* rfield@2528: * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. rfield@2528: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. rfield@2528: * rfield@2528: * This code is free software; you can redistribute it and/or modify it rfield@2528: * under the terms of the GNU General Public License version 2 only, as rfield@2528: * published by the Free Software Foundation. rfield@2528: * rfield@2528: * This code is distributed in the hope that it will be useful, but WITHOUT rfield@2528: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or rfield@2528: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License rfield@2528: * version 2 for more details (a copy is included in the LICENSE file that rfield@2528: * accompanied this code). rfield@2528: * rfield@2528: * You should have received a copy of the GNU General Public License version rfield@2528: * 2 along with this work; if not, write to the Free Software Foundation, rfield@2528: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. rfield@2528: * rfield@2528: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA rfield@2528: * or visit www.oracle.com if you need additional information or have any rfield@2528: * questions. rfield@2528: */ rfield@2528: rfield@2528: /* rfield@2528: * @test rfield@2528: * @bug 8046060 rfield@2528: * @summary Different results of floating point multiplication for lambda code block rfield@2528: */ rfield@2528: rfield@2528: import java.io.*; rfield@2528: import java.net.URL; rfield@2528: import com.sun.tools.classfile.*; rfield@2528: import static com.sun.tools.classfile.AccessFlags.ACC_STRICT; rfield@2528: rfield@2528: public class LambdaTestStrictFPFlag { rfield@2528: public static void main(String[] args) throws Exception { rfield@2528: new LambdaTestStrictFPFlag().run(); rfield@2528: } rfield@2528: rfield@2528: void run() throws Exception { rfield@2528: ClassFile cf = getClassFile("LambdaTestStrictFPFlag$Test.class"); rfield@2528: ConstantPool cp = cf.constant_pool; rfield@2528: boolean found = false; rfield@2528: for (Method meth: cf.methods) { rfield@2528: if (meth.getName(cp).startsWith("lambda$")) { rfield@2528: if ((meth.access_flags.flags & ACC_STRICT) == 0) { rfield@2528: throw new Exception("strict flag missing from lambda"); rfield@2528: } rfield@2528: found = true; rfield@2528: } rfield@2528: } rfield@2528: if (!found) { rfield@2528: throw new Exception("did not find lambda method"); rfield@2528: } rfield@2528: } rfield@2528: rfield@2528: ClassFile getClassFile(String name) throws IOException, ConstantPoolException { rfield@2528: URL url = getClass().getResource(name); rfield@2528: InputStream in = url.openStream(); rfield@2528: try { rfield@2528: return ClassFile.read(in); rfield@2528: } finally { rfield@2528: in.close(); rfield@2528: } rfield@2528: } rfield@2528: rfield@2528: class Test { rfield@2528: strictfp void test() { rfield@2528: Face itf = () -> { }; rfield@2528: } rfield@2528: } rfield@2528: rfield@2528: interface Face { rfield@2528: void m(); rfield@2528: } rfield@2528: }