author | vlivanov |
Thu, 30 May 2019 13:39:13 +0300 | |
changeset 55105 | 9ad765641e8f |
child 55749 | cff8aad2593f |
permissions | -rw-r--r-- |
55105
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
1 |
/* |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
4 |
* |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
8 |
* |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
13 |
* accompanied this code). |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
14 |
* |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
18 |
* |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
21 |
* questions. |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
22 |
*/ |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
23 |
|
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
24 |
#include <jni.h> |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
25 |
|
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
26 |
static jmethodID methodId; |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
27 |
|
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
28 |
extern "C" { |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
29 |
JNIEXPORT jboolean JNICALL Java_ClassInitBarrier_init(JNIEnv* env, jclass cls) { |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
30 |
jclass runnable = env->FindClass("java/lang/Runnable"); |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
31 |
if (runnable == NULL) return JNI_FALSE; |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
32 |
|
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
33 |
methodId = env->GetMethodID(runnable, "run", "()V"); |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
34 |
if (methodId == NULL) return JNI_FALSE; |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
35 |
|
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
36 |
return JNI_TRUE; |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
37 |
} |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
38 |
|
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
39 |
JNIEXPORT void JNICALL Java_ClassInitBarrier_00024Test_00024A_staticN(JNIEnv* env, jclass cls, jobject action) { |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
40 |
env->CallVoidMethod(action, methodId); |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
41 |
} |
9ad765641e8f
8223213: Implement fast class initialization checks on x86-64
vlivanov
parents:
diff
changeset
|
42 |
} |