< prev index next >

src/hotspot/share/prims/jni.cpp

Print this page
*** 2716,10 ***
--- 2716,14 ---
      THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR);
    }
  
    Handle obj(thread, JNIHandles::resolve_non_null(jobj));
    ObjectSynchronizer::jni_enter(obj, thread);
+   if (!Continuation::pin(thread)) {
+     ObjectSynchronizer::jni_exit(obj(), CHECK_(JNI_ERR));
+     THROW_(vmSymbols::java_lang_IllegalMonitorStateException(), JNI_ERR);
+   }
    ret = JNI_OK;
    return ret;
  JNI_END
  
  DT_RETURN_MARK_DECL(MonitorExit, jint

*** 2735,11 ***
      THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR);
    }
  
    Handle obj(THREAD, JNIHandles::resolve_non_null(jobj));
    ObjectSynchronizer::jni_exit(obj(), CHECK_(JNI_ERR));
! 
    ret = JNI_OK;
    return ret;
  JNI_END
  
  //
--- 2739,13 ---
      THROW_(vmSymbols::java_lang_NullPointerException(), JNI_ERR);
    }
  
    Handle obj(THREAD, JNIHandles::resolve_non_null(jobj));
    ObjectSynchronizer::jni_exit(obj(), CHECK_(JNI_ERR));
!   if (!Continuation::unpin(thread)) {
+     THROW_(vmSymbols::java_lang_IllegalMonitorStateException(), JNI_ERR);
+   }
    ret = JNI_OK;
    return ret;
  JNI_END
  
  //

*** 3134,10 ***
--- 3140,15 ---
  
  JNI_ENTRY(jobject, jni_GetModule(JNIEnv* env, jclass clazz))
    return Modules::get_module(clazz, THREAD);
  JNI_END
  
+ JNI_ENTRY(jboolean, jni_IsVirtualThread(JNIEnv* env, jobject obj))
+   oop thread_obj = JNIHandles::resolve_external_guard(obj);
+   return java_lang_VirtualThread::is_instance(thread_obj) ? JNI_TRUE : JNI_FALSE;
+ JNI_END
+ 
  
  // Structure containing all jni functions
  struct JNINativeInterface_ jni_NativeInterface = {
      NULL,
      NULL,

*** 3418,11 ***
  
      jni_GetObjectRefType,
  
      // Module features
  
!     jni_GetModule
  };
  
  
  // For jvmti use to modify jni function table.
  // Java threads in native contiues to run until it is transitioned
--- 3429,15 ---
  
      jni_GetObjectRefType,
  
      // Module features
  
!     jni_GetModule,
+ 
+     // Loom
+ 
+     jni_IsVirtualThread
  };
  
  
  // For jvmti use to modify jni function table.
  // Java threads in native contiues to run until it is transitioned
< prev index next >