test/compiler/6778657/Test.java

Wed, 21 Jan 2015 12:38:11 +0100

author
goetz
date
Wed, 21 Jan 2015 12:38:11 +0100
changeset 7574
a51071796915
parent 1907
c18cbe5936b8
child 6876
710a3c8b516e
permissions
-rw-r--r--

8068013: [TESTBUG] Aix support in hotspot jtreg tests
Reviewed-by: ctornqvi, fzhinkin, farvidsson

kvn@943 1 /*
trims@1907 2 * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
kvn@943 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
kvn@943 4 *
kvn@943 5 * This code is free software; you can redistribute it and/or modify it
kvn@943 6 * under the terms of the GNU General Public License version 2 only, as
kvn@943 7 * published by the Free Software Foundation.
kvn@943 8 *
kvn@943 9 * This code is distributed in the hope that it will be useful, but WITHOUT
kvn@943 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
kvn@943 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kvn@943 12 * version 2 for more details (a copy is included in the LICENSE file that
kvn@943 13 * accompanied this code).
kvn@943 14 *
kvn@943 15 * You should have received a copy of the GNU General Public License version
kvn@943 16 * 2 along with this work; if not, write to the Free Software Foundation,
kvn@943 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
kvn@943 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
kvn@943 22 *
kvn@943 23 */
kvn@943 24
kvn@943 25 /*
kvn@943 26 * @test
kvn@943 27 * @bug 6778657
kvn@943 28 * @summary Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn@943 29 */
kvn@943 30
kvn@943 31 public class Test {
kvn@943 32 public static void check_f2i(int expect) {
kvn@943 33 float check = expect;
kvn@943 34 check *= 2;
kvn@943 35 int actual = (int) check;
kvn@943 36 if (actual != expect)
kvn@943 37 throw new RuntimeException("expecting " + expect + ", got " + actual);
kvn@943 38 }
kvn@943 39
kvn@943 40 public static void check_f2l(long expect) {
kvn@943 41 float check = expect;
kvn@943 42 check *= 2;
kvn@943 43 long actual = (long) check;
kvn@943 44 if (actual != expect)
kvn@943 45 throw new RuntimeException("expecting " + expect + ", got " + actual);
kvn@943 46 }
kvn@943 47
kvn@943 48 public static void check_d2i(int expect) {
kvn@943 49 double check = expect;
kvn@943 50 check *= 2;
kvn@943 51 int actual = (int) check;
kvn@943 52 if (actual != expect)
kvn@943 53 throw new RuntimeException("expecting " + expect + ", got " + actual);
kvn@943 54 }
kvn@943 55
kvn@943 56 public static void check_d2l(long expect) {
kvn@943 57 double check = expect;
kvn@943 58 check *= 2;
kvn@943 59 long actual = (long) check;
kvn@943 60 if (actual != expect)
kvn@943 61 throw new RuntimeException("expecting " + expect + ", got " + actual);
kvn@943 62 }
kvn@943 63
kvn@943 64 public static void main(String[] args) {
kvn@943 65 check_f2i(Integer.MAX_VALUE);
kvn@943 66 check_f2i(Integer.MIN_VALUE);
kvn@943 67 check_f2l(Long.MAX_VALUE);
kvn@943 68 check_f2l(Long.MIN_VALUE);
kvn@943 69 check_d2i(Integer.MAX_VALUE);
kvn@943 70 check_d2i(Integer.MIN_VALUE);
kvn@943 71 check_d2l(Long.MAX_VALUE);
kvn@943 72 check_d2l(Long.MIN_VALUE);
kvn@943 73 }
kvn@943 74 }
kvn@943 75

mercurial