diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt index 57491bf8a30..c89e1930503 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/reflectClassUtil.kt @@ -21,8 +21,8 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import java.lang.reflect.Array -public val Class<*>.classLoader: ClassLoader - get() = getClassLoader() ?: ClassLoader.getSystemClassLoader() +public val Class<*>.safeClassLoader: ClassLoader + get() = classLoader ?: ClassLoader.getSystemClassLoader() public fun Class<*>.isEnumClassOrSpecializedEnumEntryClass(): Boolean = javaClass>().isAssignableFrom(this) diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt index 9c2645b0f6e..53d5718feb6 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/KDeclarationContainerImpl.kt @@ -20,8 +20,8 @@ import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.load.java.structure.reflect.classId -import org.jetbrains.kotlin.load.java.structure.reflect.classLoader import org.jetbrains.kotlin.load.java.structure.reflect.createArrayType +import org.jetbrains.kotlin.load.java.structure.reflect.safeClassLoader import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.scopes.JetScope @@ -184,7 +184,7 @@ abstract class KDeclarationContainerImpl : ClassBasedDeclarationContainer { } private fun loadParameterTypes(nameResolver: NameResolver, signature: JvmProtoBuf.JvmMethodSignature): Array> { - val classLoader = jClass.classLoader + val classLoader = jClass.safeClassLoader return signature.getParameterTypeList().map { jvmType -> loadJvmType(jvmType, nameResolver, classLoader) }.toTypedArray() @@ -221,7 +221,7 @@ abstract class KDeclarationContainerImpl : ClassBasedDeclarationContainer { val implClassName = nameResolver.getName(proto.getExtension(JvmProtoBuf.implClassName)) // TODO: store fq name of impl class name in jvm_descriptors.proto val classId = ClassId(jClass.classId.getPackageFqName(), implClassName) - return jClass.classLoader.loadClass(classId.asSingleFqName().asString()) + return jClass.safeClassLoader.loadClass(classId.asSingleFqName().asString()) } private fun loadJvmType( diff --git a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/moduleByClassLoader.kt b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/moduleByClassLoader.kt index c092c5257f3..d578e2bf6bd 100644 --- a/core/reflection.jvm/src/kotlin/reflect/jvm/internal/moduleByClassLoader.kt +++ b/core/reflection.jvm/src/kotlin/reflect/jvm/internal/moduleByClassLoader.kt @@ -16,7 +16,7 @@ package kotlin.reflect.jvm.internal -import org.jetbrains.kotlin.load.java.structure.reflect.classLoader +import org.jetbrains.kotlin.load.java.structure.reflect.safeClassLoader import org.jetbrains.kotlin.load.kotlin.reflect.RuntimeModuleData import java.lang.ref.WeakReference import java.util.concurrent.ConcurrentHashMap @@ -45,7 +45,7 @@ private class WeakClassLoaderBox(classLoader: ClassLoader) { } private fun Class<*>.getOrCreateModule(): RuntimeModuleData { - val classLoader = this.classLoader + val classLoader = this.safeClassLoader val key = WeakClassLoaderBox(classLoader) val cached = moduleByClassLoader[key]