|
1 /* |
|
2 * Copyright (c) 2015, 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 package compiler.calls.common; |
|
25 |
|
26 import jdk.test.lib.Asserts; |
|
27 |
|
28 /** |
|
29 * A test class checking InvokeStatic instruction |
|
30 */ |
|
31 public class InvokeStatic extends CallsBase { |
|
32 private static final Object LOCK = new Object(); |
|
33 |
|
34 public static void main(String args[]) { |
|
35 new InvokeStatic().runTest(args); |
|
36 } |
|
37 |
|
38 /** |
|
39 * A native caller method, assumed to called "callee"/"calleeNative" |
|
40 */ |
|
41 @Override |
|
42 public native void callerNative(); |
|
43 |
|
44 /** |
|
45 * A caller method, assumed to called "callee"/"calleeNative" |
|
46 */ |
|
47 @Override |
|
48 public void caller() { |
|
49 if (nativeCallee) { |
|
50 Asserts.assertTrue(calleeNative(this, 1, 2L, 3.0f, 4.0d, "5"), |
|
51 CALL_ERR_MSG); |
|
52 } else { |
|
53 Asserts.assertTrue(callee(this, 1, 2L, 3.0f, 4.0d, "5"), |
|
54 CALL_ERR_MSG); |
|
55 } |
|
56 } |
|
57 |
|
58 /** |
|
59 * A callee method, assumed to be called by "caller"/"callerNative" |
|
60 */ |
|
61 public static boolean callee(InvokeStatic instance, int param1, |
|
62 long param2, float param3, double param4, String param5) { |
|
63 instance.calleeVisited = true; |
|
64 CallsBase.checkValues(param1, param2, param3, param4, param5); |
|
65 return true; |
|
66 } |
|
67 |
|
68 /** |
|
69 * A native callee method, assumed to be called by "caller"/"callerNative" |
|
70 */ |
|
71 public static native boolean calleeNative(InvokeStatic instance, |
|
72 int param1, long param2, float param3, double param4, String param5); |
|
73 |
|
74 /** |
|
75 * Returns object to lock execution on |
|
76 * @return lock object |
|
77 */ |
|
78 @Override |
|
79 protected Object getLockObject() { |
|
80 return LOCK; |
|
81 } |
|
82 |
|
83 /** |
|
84 * Provides callee parameters types to search method |
|
85 * @return array of types |
|
86 */ |
|
87 protected Class[] getCalleeParametersTypes() { |
|
88 return new Class[]{InvokeStatic.class, int.class, long.class, |
|
89 float.class, double.class, String.class}; |
|
90 } |
|
91 } |