Disregard PlatformImplementation class loaded from parent classloader
Such type cannot be cast to a base type, if the former is loaded from a different, parent classloader. #KT-47857 Fixed Co-authored-by: Aleksei.Cherepanov <aleksei.cherepanov@jetbrains.com>
This commit is contained in:
committed by
teamcityserver
parent
c2ab91d048
commit
d7c31fbe82
@@ -77,7 +77,10 @@ private inline fun <reified T : Any> castToBaseType(instance: Any): T {
|
||||
} catch (e: ClassCastException) {
|
||||
val instanceCL = instance.javaClass.classLoader
|
||||
val baseTypeCL = T::class.java.classLoader
|
||||
throw ClassCastException("Instance classloader: $instanceCL, base type classloader: $baseTypeCL").initCause(e)
|
||||
if (instanceCL != baseTypeCL) {
|
||||
throw ClassNotFoundException("Instance class was loaded from a different classloader: $instanceCL, base type classloader: $baseTypeCL", e)
|
||||
}
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user