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: public class LambdaTestStrictFPMethod { rfield@2528: rfield@2528: public static void main(String args[]) { rfield@2528: new LambdaTestStrictFPMethod().test(); rfield@2528: } rfield@2528: rfield@2528: strictfp void test() { rfield@2528: double result = eval(() -> { rfield@2528: double x = Double.longBitsToDouble(0x1e7ee00000000000L); rfield@2528: double y = Double.longBitsToDouble(0x2180101010101010L); rfield@2528: rfield@2528: return x * y; rfield@2528: }); rfield@2528: { rfield@2528: double x = Double.longBitsToDouble(0x1e7ee00000000000L); rfield@2528: double y = Double.longBitsToDouble(0x2180101010101010L); rfield@2528: rfield@2528: double z = x * y; rfield@2528: check(z, result, "method"); rfield@2528: } rfield@2528: } rfield@2528: rfield@2528: strictfp void check(double expected, double got, String where) { rfield@2528: if (got != expected) { rfield@2528: throw new AssertionError(where + ": Non-strictfp " + got + " != " + expected); rfield@2528: } rfield@2528: } rfield@2528: rfield@2528: static double eval(Face arg) { rfield@2528: return arg.m(); rfield@2528: } rfield@2528: rfield@2528: interface Face { rfield@2528: double m(); rfield@2528: } rfield@2528: }