test/compiler/6778657/Test.java

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 943
6d8fc951eb25
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

kvn@943 1 /*
xdono@1014 2 * Copyright 2008-2009 Sun Microsystems, Inc. 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 *
kvn@943 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
kvn@943 20 * CA 95054 USA or visit www.sun.com if you need additional information or
kvn@943 21 * have any 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