File tree Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Expand file tree Collapse file tree 4 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ namespace jni {
31
31
32
32
static Type get_type ();
33
33
34
+ static bool is_initialized ();
35
+
34
36
private:
35
37
Jvm () = default ;
36
38
static JavaVM* vm;
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ namespace jni {
45
45
Jvm::Type Jvm::get_type () {
46
46
return vm_type;
47
47
}
48
+
49
+ bool Jvm::is_initialized () {
50
+ return true ;
51
+ }
48
52
}// namespace jni
49
53
50
54
#endif
Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ namespace jni {
100
100
Jvm::Type Jvm::get_type () {
101
101
return vm_type;
102
102
}
103
+
104
+ bool Jvm::is_initialized () {
105
+ return vm;
106
+ }
103
107
}// namespace jni
104
108
105
109
#endif
Original file line number Diff line number Diff line change @@ -277,10 +277,26 @@ void KotlinLanguage::remove_named_global_constant(const StringName& p_name) {
277
277
}
278
278
279
279
void KotlinLanguage::thread_enter () {
280
+ // TODO: Remove this ifdef and its content while reworking GDKotlin and moving out logic of finding JVM.
281
+ #ifdef DEBUG_ENABLED
282
+ if (!jni::Jvm::is_initialized ()) {
283
+ LOG_ERROR (" JavaVM is not initialized, please make sure your project contains an embedded JVM or JAVA_HOME environment variable is setup" );
284
+ return ;
285
+ }
286
+ #endif
287
+
280
288
jni::Jvm::attach ();
281
289
}
282
290
283
291
void KotlinLanguage::thread_exit () {
292
+ // TODO: Remove this ifdef and its content while reworking GDKotlin and moving out logic of finding JVM.
293
+ #ifdef DEBUG_ENABLED
294
+ if (!jni::Jvm::is_initialized ()) {
295
+ LOG_ERROR (" JavaVM is not initialized, please make sure your project contains an embedded JVM or JAVA_HOME environment variable is setup" );
296
+ return ;
297
+ }
298
+ #endif
299
+
284
300
jni::Jvm::detach ();
285
301
}
286
302
You can’t perform that action at this time.
0 commit comments