Store ABI version along with serialized descriptors

KotlinInfo annotation now has a version() field, which should be equal to the
compiler's JvmAbi.VERSION in order for this class to properly load and be used.

Create ErrorReporter class, which has a trace to which it can report errors
(now only related to ABI version). This is done because a dependency of
DeserializedDescriptorResolver from BindingTrace would be confusing.
Implementation of ErrorReporter will probably need to change when we untie
deserialization from java-resolve.

Check if PsiClass is actually a compiled class before trying to load serialized
data from it: otherwise it can be a Java source, as was in wrongAbiVersion()
test, and ASM will fail when trying to read that file. Rewrite the test so that
it now has a compiled Kotlin classes to check against (also include sources to
recompile this binary data later, although it won't probably be needed)
This commit is contained in:
Alexander Udalov
2013-07-09 21:04:39 +04:00
parent cc4fd008ad
commit 6ae81c3ade
20 changed files with 170 additions and 68 deletions
@@ -228,6 +228,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
ClassData data = new ClassData(createNameResolver(serializer.getNameTable()), classProto);
AnnotationVisitor av = v.getVisitor().visitAnnotation(JvmStdlibNames.KOTLIN_INFO_CLASS.getDescriptor(), true);
av.visit("version", JvmAbi.VERSION);
AnnotationVisitor array = av.visitArray("data");
for (String string : JavaProtoBufUtil.encodeBytes(data.toBytes())) {
array.visit(null, string);
@@ -162,6 +162,7 @@ public class NamespaceCodegen extends MemberCodegen {
PackageData data = new PackageData(createNameResolver(serializer.getNameTable()), packageProto.build());
AnnotationVisitor av = v.getClassBuilder().newAnnotation(JvmStdlibNames.KOTLIN_INFO_CLASS.getDescriptor(), true);
av.visit("version", JvmAbi.VERSION);
AnnotationVisitor array = av.visitArray("data");
for (String string : JavaProtoBufUtil.encodeBytes(data.toBytes())) {
array.visit(null, string);