kotlinx.reflect.lite.descriptors.impl.ModuleDescriptorImpl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlinx.reflect.lite Show documentation
Show all versions of kotlinx.reflect.lite Show documentation
Experimental lightweight library that replaces existing 'kotlin-reflect' implementation
The newest version!
/*
* Copyright 2016-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.reflect.lite.descriptors.impl
import kotlin.metadata.*
import kotlin.metadata.internal.common.*
import kotlin.metadata.jvm.*
import kotlinx.reflect.lite.builtins.*
import kotlinx.reflect.lite.descriptors.ClassDescriptor
import kotlinx.reflect.lite.descriptors.ModuleDescriptor
import kotlinx.reflect.lite.impl.*
import kotlinx.reflect.lite.jvm.*
import kotlinx.reflect.lite.misc.*
import kotlinx.reflect.lite.name.*
internal class ModuleDescriptorImpl(private val classLoader: ClassLoader) : ModuleDescriptor {
override fun findClass (name: ClassName): ClassDescriptor? {
val fqName = (JavaToKotlinClassMap.mapKotlinToJava(FqName(name.replace('/', '.'))) ?: ClassId(name)).asJavaLookupFqName()
val jClass = when (fqName) { // todo why arrays are hardcoded
"kotlin.BooleanArray" -> BooleanArray::class.java
"kotlin.ByteArray" -> ByteArray::class.java
"kotlin.CharArray" -> CharArray::class.java
"kotlin.DoubleArray" -> DoubleArray::class.java
"kotlin.FloatArray" -> FloatArray::class.java
"kotlin.IntArray" -> IntArray::class.java
"kotlin.LongArray" -> LongArray::class.java
"kotlin.ShortArray" -> ShortArray::class.java
"kotlin.Array" -> Array::class.java
else -> classLoader.tryLoadClass(fqName)
}
@Suppress("UNCHECKED_CAST")
return (jClass?.kotlin as KClassImpl?)?.descriptor
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy