KT-57207 Implement JavaClassFinder.findClasses
- This change is a prerequisite for allowing combined Java symbol providers (in LL FIR) to correctly disambiguate classpath order after getting classes with a combined scope, as the index access of the combined Java symbol provider is not guaranteed to return the class that should be first based on the original dependency order. To be able to disambiguate, a combined Java symbol provider needs access to all class candidates the index can find.
This commit is contained in:
committed by
Space Team
parent
f2e3c593a1
commit
567abd2a1c
+3
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.load.java.structure.JavaPackage
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.descriptors.runtime.structure.ReflectJavaClass
|
||||
import org.jetbrains.kotlin.descriptors.runtime.structure.ReflectJavaPackage
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
|
||||
class ReflectJavaClassFinder(private val classLoader: ClassLoader) : JavaClassFinder {
|
||||
override fun findClass(request: JavaClassFinder.Request): JavaClass? {
|
||||
@@ -36,6 +37,8 @@ class ReflectJavaClassFinder(private val classLoader: ClassLoader) : JavaClassFi
|
||||
return if (klass != null) ReflectJavaClass(klass) else null
|
||||
}
|
||||
|
||||
override fun findClasses(request: JavaClassFinder.Request): List<JavaClass> = listOfNotNull(findClass(request))
|
||||
|
||||
override fun findPackage(fqName: FqName, mayHaveAnnotations: Boolean): JavaPackage? {
|
||||
// We don't know which packages our class loader has and has not, so we behave as if it contains any package in the world
|
||||
return ReflectJavaPackage(fqName)
|
||||
|
||||
Reference in New Issue
Block a user