mirror of
https://github.com/signalapp/libsignal.git
synced 2026-05-08 16:13:04 +02:00
Use the class loader from the main thread to cache java.lang.Class instances for some libsignal classes. This enables constructing instances of libsignal classes on threads where the classes aren't accessible via the default class loader. This can occur on Android, where threads spawned via the native API only get access to the system class loader, not the application loader that has access to the application's class files. Since Tokio worker threads are spawned via the native API, and the completion process for async tasks converts results to Java objects, application class instances can't be used there unless they are preloaded. Since classes used in client code are only included in the client .jar file, failure to load classes is a normal occurrence. If there are ever separate builds for server and client .so library files, this could be changed to a fatal error.