annotate test/compiler/6778657/Test.java @ 579:0fbdb4381b99

6814575: Update copyright year Summary: Update copyright for files that have been modified in 2009, up to 03/09 Reviewed-by: katleman, tbell, ohair
author xdono
date Mon, 09 Mar 2009 13:28:46 -0700
parents 6d8fc951eb25
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
508
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
1 /*
579
0fbdb4381b99 6814575: Update copyright year
xdono
parents: 508
diff changeset
2 * Copyright 2008-2009 Sun Microsystems, Inc. All Rights Reserved.
508
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
4 *
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
7 * published by the Free Software Foundation.
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
8 *
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
13 * accompanied this code).
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
14 *
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
18 *
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
21 * have any questions.
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
22 *
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
23 */
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
24
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
25 /*
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
26 * @test
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
27 * @bug 6778657
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
28 * @summary Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
29 */
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
30
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
31 public class Test {
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
32 public static void check_f2i(int expect) {
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
33 float check = expect;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
34 check *= 2;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
35 int actual = (int) check;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
36 if (actual != expect)
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
37 throw new RuntimeException("expecting " + expect + ", got " + actual);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
38 }
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
39
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
40 public static void check_f2l(long expect) {
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
41 float check = expect;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
42 check *= 2;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
43 long actual = (long) check;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
44 if (actual != expect)
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
45 throw new RuntimeException("expecting " + expect + ", got " + actual);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
46 }
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
47
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
48 public static void check_d2i(int expect) {
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
49 double check = expect;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
50 check *= 2;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
51 int actual = (int) check;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
52 if (actual != expect)
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
53 throw new RuntimeException("expecting " + expect + ", got " + actual);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
54 }
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
55
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
56 public static void check_d2l(long expect) {
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
57 double check = expect;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
58 check *= 2;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
59 long actual = (long) check;
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
60 if (actual != expect)
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
61 throw new RuntimeException("expecting " + expect + ", got " + actual);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
62 }
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
63
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
64 public static void main(String[] args) {
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
65 check_f2i(Integer.MAX_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
66 check_f2i(Integer.MIN_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
67 check_f2l(Long.MAX_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
68 check_f2l(Long.MIN_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
69 check_d2i(Integer.MAX_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
70 check_d2i(Integer.MIN_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
71 check_d2l(Long.MAX_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
72 check_d2l(Long.MIN_VALUE);
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
73 }
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
74 }
6d8fc951eb25 6778657: Casts in SharedRuntime::f2i, f2l, d2i and d2l rely on undefined C++ behaviour
kvn
parents:
diff changeset
75