Use ASM 6 API to read class files in IDE
Otherwise ASM throws exceptions trying to read module-info.class #KT-13072 Fixed
This commit is contained in:
@@ -22,6 +22,7 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
|
||||
class KotlinBinaryClassCache : Disposable {
|
||||
private class RequestCache {
|
||||
@@ -55,6 +56,8 @@ class KotlinBinaryClassCache : Disposable {
|
||||
fun getKotlinBinaryClass(file: VirtualFile, fileContent: ByteArray? = null): KotlinJvmBinaryClass? {
|
||||
if (file.fileType !== JavaClassFileType.INSTANCE) return null
|
||||
|
||||
if (file.name == PsiJavaModule.MODULE_INFO_CLS_FILE) return null
|
||||
|
||||
val service = ServiceManager.getService(KotlinBinaryClassCache::class.java)
|
||||
val requestCache = service.cache.get()
|
||||
|
||||
|
||||
@@ -52,12 +52,12 @@ object KotlinJvmMetadataVersionIndex : KotlinMetadataVersionIndexBase<KotlinJvmM
|
||||
|
||||
tryBlock(inputData) {
|
||||
val classReader = ClassReader(inputData.content)
|
||||
classReader.accept(object : ClassVisitor(Opcodes.ASM5) {
|
||||
classReader.accept(object : ClassVisitor(Opcodes.ASM6) {
|
||||
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
|
||||
if (desc != METADATA_DESC) return null
|
||||
|
||||
annotationPresent = true
|
||||
return object : AnnotationVisitor(Opcodes.ASM5) {
|
||||
return object : AnnotationVisitor(Opcodes.ASM6) {
|
||||
override fun visit(name: String, value: Any) {
|
||||
when (name) {
|
||||
METADATA_VERSION_FIELD_NAME -> if (value is IntArray) {
|
||||
|
||||
Reference in New Issue
Block a user