File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
kt/godot-library/godot-core-library/src/main/kotlin/godot/runtime Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,6 @@ internal class Bootstrap {
3333 }
3434
3535 fun finish () {
36- Thread .currentThread().contextClassLoader = null
3736 clearClassesCache()
3837 serviceLoader.reload()
3938 }
Original file line number Diff line number Diff line change @@ -251,6 +251,8 @@ bool GDKotlin::load_bootstrap() {
251251
252252 JVM_LOG_VERBOSE (" Loading bootstrap jar: %s" , bootstrap_jar);
253253 bootstrap_class_loader = ClassLoader::create_instance (env, bootstrap_jar, jni::JObject (nullptr ));
254+
255+ // set context classloader to bootstrap initially
254256 bootstrap_class_loader->set_as_context_loader (env);
255257 }
256258
@@ -318,6 +320,9 @@ bool GDKotlin::load_user_code() {
318320 bootstrap_class_loader->get_wrapped ()
319321 );
320322
323+ // update context classloader to use usercode jar
324+ user_class_loader->set_as_context_loader (env);
325+
321326 bootstrap->init_jar (env, user_class_loader->get_wrapped ());
322327 delete user_class_loader;
323328 return FileAccess::exists (user_code_path);
@@ -326,6 +331,10 @@ bool GDKotlin::load_user_code() {
326331
327332void GDKotlin::unload_user_code () {
328333 jni::Env env {jni::Jvm::current_env ()};
334+
335+ // reset context classloader to bootstrap
336+ bootstrap_class_loader->set_as_context_loader (env);
337+
329338 bootstrap->finish (env);
330339 TypeManager::get_instance ().clear ();
331340 jar.unref ();
You can’t perform that action at this time.
0 commit comments