From ac6be2edba3836ef49918eeea99705ac961f0058 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 6 Mar 2020 17:53:15 +0100 Subject: [PATCH] Treat class files with no bytecode version as having the current version This has no effect currently because all class files produced by Kotlin have the bytecode version in the metadata (currently 1.0.3). However, this change will allow us to stop writing bytecode version to metadata in Kotlin 1.5. In fact, we could do it while the default here was INVALID_VERSION too, but then for example compiling with Kotlin 1.3 against binaries of version 1.5 would lead to extraneous "incompatible bytecode version" errors (because INVALID_VERSION is basically 0, which is incompatible to 1.0.3+), in addition to the correct "incompatible metadata version" error. The reason why we might want to avoid writing bytecode version is the fact that the initial use case it was added for is already supported by the metadata version, and the bytecode version error reporting was never fully implemented. Actually bytecode version was almost unused because of that. --- .../kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java index 3cb3c74b6db..85cfc82d1d2 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/kotlin/header/ReadKotlinClassHeaderAnnotationVisitor.java @@ -82,7 +82,7 @@ public class ReadKotlinClassHeaderAnnotationVisitor implements AnnotationVisitor return new KotlinClassHeader( headerKind, metadataVersion, - bytecodeVersion != null ? bytecodeVersion : JvmBytecodeBinaryVersion.INVALID_VERSION, + bytecodeVersion != null ? bytecodeVersion : JvmBytecodeBinaryVersion.INSTANCE, data, incompatibleData, strings,