KT-45777: Remove proto-based approach to compute Java class snapshots
as the ASM-based approach is better, and we have switched to the ASM-based approach for a while now.
This commit is contained in:
committed by
nataliya.valtman
parent
f819a10968
commit
1cb509d529
+9
-19
@@ -32,15 +32,13 @@ import java.text.CharacterIterator
|
||||
import java.text.StringCharacterIterator
|
||||
|
||||
class BinaryJavaClass(
|
||||
/** If virtualFile is not available, provide classContent & innerClassFinder below. */
|
||||
override val virtualFile: VirtualFile? = null,
|
||||
override val virtualFile: VirtualFile,
|
||||
override val fqName: FqName,
|
||||
internal val context: ClassifierResolutionContext,
|
||||
private val signatureParser: BinaryClassSignatureParser,
|
||||
override var access: Int = 0,
|
||||
override val outerClass: JavaClass?,
|
||||
classContent: ByteArray? = null,
|
||||
private val innerClassFinder: ((Name) -> JavaClass?)? = null
|
||||
classContent: ByteArray? = null
|
||||
) : ClassVisitor(ASM_API_VERSION_FOR_CLASS_READING), VirtualFileBoundJavaClass, BinaryJavaModifierListOwner, MutableJavaAnnotationOwner {
|
||||
override val annotations: MutableCollection<JavaAnnotation> = SmartList()
|
||||
|
||||
@@ -113,17 +111,13 @@ class BinaryJavaClass(
|
||||
}
|
||||
|
||||
init {
|
||||
if (virtualFile == null) {
|
||||
checkNotNull(classContent) { "classContent must be provided when virtualFile is not available" }
|
||||
checkNotNull(innerClassFinder) { "innerClassFinder must be provided when virtualFile is not available" }
|
||||
}
|
||||
try {
|
||||
ClassReader(classContent ?: virtualFile!!.contentsToByteArray()).accept(
|
||||
ClassReader(classContent ?: virtualFile.contentsToByteArray()).accept(
|
||||
this,
|
||||
ClassReader.SKIP_CODE or ClassReader.SKIP_FRAMES
|
||||
)
|
||||
} catch (e: Throwable) {
|
||||
throw IllegalStateException("Could not read class " + (virtualFile ?: ""), e)
|
||||
throw IllegalStateException("Could not read class: $virtualFile", e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,15 +247,11 @@ class BinaryJavaClass(
|
||||
fun findInnerClass(name: Name, classFileContent: ByteArray?): JavaClass? {
|
||||
val access = ownInnerClassNameToAccess[name] ?: return null
|
||||
|
||||
return if (virtualFile != null) {
|
||||
virtualFile.parent.findChild("${virtualFile.nameWithoutExtension}$$name.class")?.let {
|
||||
BinaryJavaClass(
|
||||
it, fqName.child(name), context.copyForMember(), signatureParser, access, this,
|
||||
classFileContent
|
||||
)
|
||||
}
|
||||
} else {
|
||||
innerClassFinder!!(name)
|
||||
return virtualFile.parent.findChild("${virtualFile.nameWithoutExtension}$$name.class")?.let {
|
||||
BinaryJavaClass(
|
||||
it, fqName.child(name), context.copyForMember(), signatureParser, access, this,
|
||||
classFileContent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user