Use correct class loader in kotlinx-metadata to load MetadataExtensions implementations

By default, ServiceLoader.load uses thread context class loader, which
can differ from the MetadataExtensions' class loader (which also loads
JvmMetadataExtensions, since they're in the same .jar) in many cases,
for example when used in annotation processing

 #KT-24881 Fixed
This commit is contained in:
Alexander Udalov
2018-06-14 16:53:48 +02:00
parent 28da071ff6
commit a9974a522e
2 changed files with 2 additions and 1 deletions
@@ -3,6 +3,7 @@
## 0.0.3
- Support metadata of local delegated properties (see `JvmDeclarationContainerExtensionVisitor.visitLocalDelegatedProperty`)
- [`KT-24881`](https://youtrack.jetbrains.com/issue/KT-24881) Use correct class loader in kotlinx-metadata to load MetadataExtensions implementations
## 0.0.2
@@ -46,7 +46,7 @@ interface MetadataExtensions {
companion object {
val INSTANCES: List<MetadataExtensions> by lazy {
ServiceLoader.load(MetadataExtensions::class.java).toList().also {
ServiceLoader.load(MetadataExtensions::class.java, MetadataExtensions::class.java.classLoader).toList().also {
if (it.isEmpty()) error(
"No MetadataExtensions instances found in the classpath. Please ensure that the META-INF/services/ " +
"is not stripped from your application and that the Java virtual machine is not running " +