Improve diagnostic for missing BuiltInsLoader implementation
Also initialize it lazily to avoid wrapping the exception into ExceptionInInitializerError #KT-20575
This commit is contained in:
@@ -34,7 +34,12 @@ interface BuiltInsLoader {
|
||||
): PackageFragmentProvider
|
||||
|
||||
companion object {
|
||||
val Instance: BuiltInsLoader =
|
||||
ServiceLoader.load(BuiltInsLoader::class.java, BuiltInsLoader::class.java.classLoader).first()
|
||||
val Instance: BuiltInsLoader by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
val implementations = ServiceLoader.load(BuiltInsLoader::class.java, BuiltInsLoader::class.java.classLoader)
|
||||
implementations.firstOrNull() ?: throw IllegalStateException(
|
||||
"No BuiltInsLoader implementation was found. Please ensure that the META-INF/services/ is not stripped " +
|
||||
"from your application and that the Java virtual machine is not running under a security manager"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user