|
1 /* |
|
2 * Copyright (c) 2018 SAP SE. 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 8209637 |
|
27 * @summary [s390x] Interpreter doesn't call result handler after native calls |
|
28 * @author Volker Simonis |
|
29 * |
|
30 * @run main/othervm/native -XX:-UseOnStackReplacement -Xbatch JNIBooleanTest 50000 |
|
31 * @run main/othervm/native -Xint JNIBooleanTest 256 |
|
32 */ |
|
33 |
|
34 import java.lang.reflect.Method; |
|
35 |
|
36 public class JNIBooleanTest { |
|
37 static native boolean foo(byte b); |
|
38 |
|
39 static boolean bar(byte b) { |
|
40 return foo(b); |
|
41 } |
|
42 |
|
43 public static void main(String args[]) throws Exception { |
|
44 int count = args.length > 0 ? Integer.parseInt(args[0]) : 50_000; |
|
45 byte b = 0; |
|
46 for (int i = 0; i < count; i++) { |
|
47 boolean bool = foo(b); |
|
48 if ((b == 0 && bool) || (b != 0 && !bool)) { |
|
49 throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i); |
|
50 } |
|
51 b++; |
|
52 } |
|
53 |
|
54 b = 0; |
|
55 for (int i = 0; i < count; i++) { |
|
56 boolean bool = bar(b); |
|
57 if ((b == 0 && bool) || (b != 0 && !bool)) { |
|
58 throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i); |
|
59 } |
|
60 b++; |
|
61 } |
|
62 |
|
63 Method foo = JNIBooleanTest.class.getDeclaredMethod("foo", byte.class); |
|
64 |
|
65 b = 0; |
|
66 for (int i = 0; i < count; i++) { |
|
67 boolean bool = ((Boolean)foo.invoke(null, b)).booleanValue(); |
|
68 if ((b == 0 && bool) || (b != 0 && !bool)) { |
|
69 throw new RuntimeException("Error: foo(" + b + ") = " + bool + " in iteration " + i + " (reflective)"); |
|
70 } |
|
71 b++; |
|
72 } |
|
73 |
|
74 Method bar = JNIBooleanTest.class.getDeclaredMethod("bar", byte.class); |
|
75 |
|
76 b = 0; |
|
77 for (int i = 0; i < count; i++) { |
|
78 boolean bool = ((Boolean)bar.invoke(null, b)).booleanValue(); |
|
79 if ((b == 0 && bool) || (b != 0 && !bool)) { |
|
80 throw new RuntimeException("Error: bar(" + b + ") = " + bool + " in iteration " + i + " (reflective)"); |
|
81 } |
|
82 b++; |
|
83 } |
|
84 } |
|
85 |
|
86 static { |
|
87 System.loadLibrary("JNIBooleanTest"); |
|
88 } |
|
89 } |