Path: blob/master/test/hotspot/jtreg/compiler/floatingpoint/TestFloatJNIArgs.java
41152 views
/*1* Copyright (c) 2015, 2016 SAP SE. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/* @test24* @bug 8139258 816567325* @summary Regression test for passing float args to a jni function.26*27*28* @run main/othervm/native -Xint compiler.floatingpoint.TestFloatJNIArgs29* @run main/othervm/native -XX:+TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs30*/3132/* @test33* @bug 8139258 816567334* @summary Regression test for passing float args to a jni function.35*36* @requires !vm.graal.enabled37* @run main/othervm/native -XX:-TieredCompilation -Xcomp compiler.floatingpoint.TestFloatJNIArgs38*/3940package compiler.floatingpoint;4142public class TestFloatJNIArgs {43static {44try {45System.loadLibrary("TestFloatJNIArgs");46} catch (UnsatisfiedLinkError e) {47System.out.println("could not load native lib: " + e);48}49}5051public static native float add15floats(52float f1, float f2, float f3, float f4,53float f5, float f6, float f7, float f8,54float f9, float f10, float f11, float f12,55float f13, float f14, float f15);5657public static native float add10floats(58float f1, float f2, float f3, float f4,59float f5, float f6, float f7, float f8,60float f9, float f10);6162public static native float addFloatsInts(63float f1, float f2, float f3, float f4,64float f5, float f6, float f7, float f8,65float f9, float f10, float f11, float f12,66float f13, float f14, float f15, int a16, int a17);6768public static native double add15doubles(69double d1, double d2, double d3, double d4,70double d5, double d6, double d7, double d8,71double d9, double d10, double d11, double d12,72double d13, double d14, double d15);7374static void test() throws Exception {75float sum = TestFloatJNIArgs.add15floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,761.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);77if (sum != 15.0f) {78throw new Error("Passed 15 times 1.0f to jni function which didn't add them properly: " + sum);79}8081float sum1 = TestFloatJNIArgs.add10floats(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f);82if (sum1 != 10.0f) {83throw new Error("Passed 10 times 1.0f to jni function which didn't add them properly: " + sum1);84}8586float sum2 = TestFloatJNIArgs.addFloatsInts(1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,871.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1, 1);88if (sum2 != 17.0f) {89throw new Error("Passed 17 times 1 to jni function which didn't add them properly: " + sum2);90}9192double dsum = TestFloatJNIArgs.add15doubles(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0,931.0, 1.0, 1.0, 1.0, 1.0, 1.0);94if (dsum != 15.0) {95throw new Error("Passed 15 times 1.0 to jni function which didn't add them properly: " + dsum);96}97}9899public static void main(String[] args) throws Exception {100for (int i = 0; i < 200; ++i) {101test();102}103}104}105106107