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