Skip to content

Commit 79d23ee

Browse files
committed
Backport 8309171
1 parent 4d8961a commit 79d23ee

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/hotspot/share/prims/jni.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,7 +3529,8 @@ extern const struct JNIInvokeInterface_ jni_InvokeInterface;
35293529
// Global invocation API vars
35303530
enum VM_Creation_State {
35313531
NOT_CREATED = 0,
3532-
IN_PROGRESS,
3532+
IN_PROGRESS, // Most JNI operations are permitted during this phase to
3533+
// allow for initialization actions by libraries and agents.
35333534
COMPLETE
35343535
};
35353536

@@ -3751,7 +3752,7 @@ static jint JNICALL jni_DestroyJavaVM_inner(JavaVM *vm) {
37513752
jint res = JNI_ERR;
37523753
DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res);
37533754

3754-
if (vm_created != COMPLETE) {
3755+
if (vm_created == NOT_CREATED) {
37553756
res = JNI_ERR;
37563757
return res;
37573758
}
@@ -3912,7 +3913,7 @@ static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool dae
39123913

39133914
jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) {
39143915
HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY(vm, penv, _args);
3915-
if (vm_created != COMPLETE) {
3916+
if (vm_created == NOT_CREATED) {
39163917
// Not sure how we could possibly get here.
39173918
HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN((uint32_t) JNI_ERR);
39183919
return JNI_ERR;
@@ -3926,7 +3927,7 @@ jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) {
39263927

39273928
jint JNICALL jni_DetachCurrentThread(JavaVM *vm) {
39283929
HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY(vm);
3929-
if (vm_created != COMPLETE) {
3930+
if (vm_created == NOT_CREATED) {
39303931
// Not sure how we could possibly get here.
39313932
HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_ERR);
39323933
return JNI_ERR;
@@ -3990,9 +3991,6 @@ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) {
39903991
jint ret = JNI_ERR;
39913992
DT_RETURN_MARK(GetEnv, jint, (const jint&)ret);
39923993

3993-
// We can be called by native libraries in the JDK during VM
3994-
// initialization, so only bail-out if something seems very wrong.
3995-
// Though how would we get here in that case?
39963994
if (vm_created == NOT_CREATED) {
39973995
*penv = NULL;
39983996
ret = JNI_EDETACHED;
@@ -4044,9 +4042,9 @@ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) {
40444042

40454043
jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_args) {
40464044
HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY(vm, penv, _args);
4047-
if (vm_created != COMPLETE) {
4045+
if (vm_created == NOT_CREATED) {
40484046
// Not sure how we could possibly get here.
4049-
HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN((uint32_t) JNI_ERR);
4047+
HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN((uint32_t) JNI_ERR);
40504048
return JNI_ERR;
40514049
}
40524050

0 commit comments

Comments
 (0)