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.
This commit is contained in:
Alexander Udalov
2020-03-06 17:53:15 +01:00
parent 787e4503e5
commit ac6be2edba
@@ -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,