Sat, 22 Dec 2018 13:10:38 -0800
Added tag jdk8u202-b25 for changeset 15d8c732039b
rfield@2528 | 1 | /* |
rfield@2528 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
rfield@2528 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
rfield@2528 | 4 | * |
rfield@2528 | 5 | * This code is free software; you can redistribute it and/or modify it |
rfield@2528 | 6 | * under the terms of the GNU General Public License version 2 only, as |
rfield@2528 | 7 | * published by the Free Software Foundation. |
rfield@2528 | 8 | * |
rfield@2528 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
rfield@2528 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
rfield@2528 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
rfield@2528 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
rfield@2528 | 13 | * accompanied this code). |
rfield@2528 | 14 | * |
rfield@2528 | 15 | * You should have received a copy of the GNU General Public License version |
rfield@2528 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
rfield@2528 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
rfield@2528 | 18 | * |
rfield@2528 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
rfield@2528 | 20 | * or visit www.oracle.com if you need additional information or have any |
rfield@2528 | 21 | * questions. |
rfield@2528 | 22 | */ |
rfield@2528 | 23 | |
rfield@2528 | 24 | /* |
rfield@2528 | 25 | * @test |
rfield@2528 | 26 | * @bug 8046060 |
rfield@2528 | 27 | * @summary Different results of floating point multiplication for lambda code block |
rfield@2528 | 28 | */ |
rfield@2528 | 29 | |
rfield@2528 | 30 | import java.io.*; |
rfield@2528 | 31 | import java.net.URL; |
rfield@2528 | 32 | import com.sun.tools.classfile.*; |
rfield@2528 | 33 | import static com.sun.tools.classfile.AccessFlags.ACC_STRICT; |
rfield@2528 | 34 | |
rfield@2528 | 35 | public class LambdaTestStrictFPFlag { |
rfield@2528 | 36 | public static void main(String[] args) throws Exception { |
rfield@2528 | 37 | new LambdaTestStrictFPFlag().run(); |
rfield@2528 | 38 | } |
rfield@2528 | 39 | |
rfield@2528 | 40 | void run() throws Exception { |
rfield@2528 | 41 | ClassFile cf = getClassFile("LambdaTestStrictFPFlag$Test.class"); |
rfield@2528 | 42 | ConstantPool cp = cf.constant_pool; |
rfield@2528 | 43 | boolean found = false; |
rfield@2528 | 44 | for (Method meth: cf.methods) { |
rfield@2528 | 45 | if (meth.getName(cp).startsWith("lambda$")) { |
rfield@2528 | 46 | if ((meth.access_flags.flags & ACC_STRICT) == 0) { |
rfield@2528 | 47 | throw new Exception("strict flag missing from lambda"); |
rfield@2528 | 48 | } |
rfield@2528 | 49 | found = true; |
rfield@2528 | 50 | } |
rfield@2528 | 51 | } |
rfield@2528 | 52 | if (!found) { |
rfield@2528 | 53 | throw new Exception("did not find lambda method"); |
rfield@2528 | 54 | } |
rfield@2528 | 55 | } |
rfield@2528 | 56 | |
rfield@2528 | 57 | ClassFile getClassFile(String name) throws IOException, ConstantPoolException { |
rfield@2528 | 58 | URL url = getClass().getResource(name); |
rfield@2528 | 59 | InputStream in = url.openStream(); |
rfield@2528 | 60 | try { |
rfield@2528 | 61 | return ClassFile.read(in); |
rfield@2528 | 62 | } finally { |
rfield@2528 | 63 | in.close(); |
rfield@2528 | 64 | } |
rfield@2528 | 65 | } |
rfield@2528 | 66 | |
rfield@2528 | 67 | class Test { |
rfield@2528 | 68 | strictfp void test() { |
rfield@2528 | 69 | Face itf = () -> { }; |
rfield@2528 | 70 | } |
rfield@2528 | 71 | } |
rfield@2528 | 72 | |
rfield@2528 | 73 | interface Face { |
rfield@2528 | 74 | void m(); |
rfield@2528 | 75 | } |
rfield@2528 | 76 | } |