Refactor KotlinJvmBinaryClass, VirtualFileKotlinClass, etc.
VirtualFileKotlinClass now reads its header and name on creation. This is not lazy enough and may be slower in some circumstances, but has the following advantage: if anything is wrong in the header, a VirtualFileKotlinClass instance will not be created at all, making it nearly impossible for the client code to operate on invalid data causing all kinds of exceptions
This commit is contained in:
+2
-2
@@ -75,8 +75,8 @@ fun LazyJavaResolverContext.findClassInJava(fqName: FqName): JavaClassLookupResu
|
||||
}
|
||||
|
||||
val kotlinClass = kotlinClassFinder.findKotlinClass(fqName)
|
||||
val header = kotlinClass?.getClassHeader()
|
||||
if (kotlinClass != null && header != null) {
|
||||
if (kotlinClass != null) {
|
||||
val header = kotlinClass.getClassHeader()
|
||||
if (header.kind == KotlinClassHeader.Kind.CLASS) {
|
||||
val descriptor = packageFragmentProvider.resolveKotlinBinaryClass(kotlinClass)
|
||||
if (descriptor != null) {
|
||||
|
||||
-2
@@ -117,8 +117,6 @@ public final class DeserializedDescriptorResolver {
|
||||
@Nullable
|
||||
private String[] readData(@NotNull KotlinJvmBinaryClass kotlinClass, @NotNull KotlinClassHeader.Kind expectedKind) {
|
||||
KotlinClassHeader header = kotlinClass.getClassHeader();
|
||||
if (header == null) return null;
|
||||
|
||||
if (header.getKind() == KotlinClassHeader.Kind.INCOMPATIBLE_ABI_VERSION) {
|
||||
errorReporter.reportIncompatibleAbiVersion(kotlinClass, header.getVersion());
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public interface KotlinJvmBinaryClass {
|
||||
|
||||
void visitMembers(@NotNull MemberVisitor visitor);
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
KotlinClassHeader getClassHeader();
|
||||
|
||||
interface MemberVisitor {
|
||||
|
||||
-11
@@ -20,7 +20,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.resolve.java.AbiVersionUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.kotlin.KotlinJvmBinaryClass;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
|
||||
@@ -53,16 +52,6 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor
|
||||
private KotlinClassHeader.Kind headerKind = null;
|
||||
private KotlinSyntheticClass.Kind syntheticClassKind = null;
|
||||
|
||||
private ReadKotlinClassHeaderAnnotationVisitor() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static KotlinClassHeader read(@NotNull KotlinJvmBinaryClass kotlinClass) {
|
||||
ReadKotlinClassHeaderAnnotationVisitor visitor = new ReadKotlinClassHeaderAnnotationVisitor();
|
||||
kotlinClass.loadClassAnnotations(visitor);
|
||||
return visitor.createHeader();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public KotlinClassHeader createHeader() {
|
||||
if (headerKind == null) {
|
||||
|
||||
Reference in New Issue
Block a user