Don't try to read binary data from a non-class file
Fixes EA-59470, where a virtual file is checked to be a compiled Kotlin class from the decompiler (which doesn't check its FileType)
This commit is contained in:
+3
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.kotlin;
|
package org.jetbrains.jet.lang.resolve.kotlin;
|
||||||
|
|
||||||
|
import com.intellij.ide.highlighter.JavaClassFileType;
|
||||||
import com.intellij.openapi.Disposable;
|
import com.intellij.openapi.Disposable;
|
||||||
import com.intellij.openapi.components.ServiceManager;
|
import com.intellij.openapi.components.ServiceManager;
|
||||||
import com.intellij.openapi.util.Ref;
|
import com.intellij.openapi.util.Ref;
|
||||||
@@ -45,6 +46,8 @@ public final class KotlinBinaryClassCache implements Disposable {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static KotlinJvmBinaryClass getKotlinBinaryClass(@NotNull VirtualFile file) {
|
public static KotlinJvmBinaryClass getKotlinBinaryClass(@NotNull VirtualFile file) {
|
||||||
|
if (file.getFileType() != JavaClassFileType.INSTANCE) return null;
|
||||||
|
|
||||||
KotlinBinaryClassCache service = ServiceManager.getService(KotlinBinaryClassCache.class);
|
KotlinBinaryClassCache service = ServiceManager.getService(KotlinBinaryClassCache.class);
|
||||||
return service.cache.get().get(file).get();
|
return service.cache.get().get(file).get();
|
||||||
}
|
}
|
||||||
|
|||||||
-7
@@ -16,9 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.kotlin
|
package org.jetbrains.jet.lang.resolve.kotlin
|
||||||
|
|
||||||
import com.intellij.ide.highlighter.JavaClassFileType
|
|
||||||
import com.intellij.openapi.vfs.VirtualFile
|
|
||||||
import org.jetbrains.annotations.Nullable
|
|
||||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaClass
|
import org.jetbrains.jet.lang.resolve.java.structure.JavaClass
|
||||||
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaClassImpl
|
import org.jetbrains.jet.lang.resolve.java.structure.impl.JavaClassImpl
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName
|
import org.jetbrains.jet.lang.resolve.name.FqName
|
||||||
@@ -38,10 +35,6 @@ public abstract class VirtualFileKotlinClassFinder() : VirtualFileFinder {
|
|||||||
file = file.getParent()!!.findChild(classFileName(javaClass) + ".class").sure("Virtual file not found for $javaClass")
|
file = file.getParent()!!.findChild(classFileName(javaClass) + ".class").sure("Virtual file not found for $javaClass")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.getFileType() != JavaClassFileType.INSTANCE) {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
return KotlinBinaryClassCache.getKotlinBinaryClass(file)
|
return KotlinBinaryClassCache.getKotlinBinaryClass(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user