Move version constants to corresponding BinaryVersion subclasses
This commit is contained in:
@@ -21,7 +21,7 @@ import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion;
|
||||
|
||||
public final class AbiVersionUtil {
|
||||
public static boolean isAbiVersionCompatible(@NotNull BinaryVersion actual) {
|
||||
return actual.isCompatibleTo(JvmAbi.VERSION);
|
||||
return actual.isCompatibleTo(JvmBytecodeBinaryVersion.INSTANCE);
|
||||
}
|
||||
|
||||
private AbiVersionUtil() {
|
||||
|
||||
@@ -32,18 +32,6 @@ import static org.jetbrains.kotlin.resolve.DescriptorUtils.isClassOrEnumClass;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.isCompanionObject;
|
||||
|
||||
public final class JvmAbi {
|
||||
/**
|
||||
* This constant is used to identify binary format (class file) versions
|
||||
* If you change class file metadata format and/or naming conventions, please change this version.
|
||||
* - Major version should be increased only when the new binary format is neither forward- nor backward compatible.
|
||||
* This shouldn't really ever happen at all.
|
||||
* - Minor version should be increased when the new format is backward compatible,
|
||||
* i.e. the new compiler can process old class files, but the old compiler will not be able to process new class files.
|
||||
* - Patch version can be increased freely and is only supposed to be used for debugging. Increase the patch version when you
|
||||
* make a change to the metadata format or the bytecode which is both forward- and backward compatible.
|
||||
*/
|
||||
public static final JvmBytecodeBinaryVersion VERSION = JvmBytecodeBinaryVersion.create(1, 0, 2);
|
||||
|
||||
public static final String DEFAULT_IMPLS_CLASS_NAME = "DefaultImpls";
|
||||
public static final String DEFAULT_IMPLS_SUFFIX = "$" + DEFAULT_IMPLS_CLASS_NAME;
|
||||
|
||||
|
||||
+3
@@ -22,6 +22,9 @@ class JvmBytecodeBinaryVersion protected constructor(
|
||||
major: Int, minor: Int, patch: Int, rest: List<Int>
|
||||
) : BinaryVersion(major, minor, patch, rest) {
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE = create(1, 0, 2)
|
||||
|
||||
@JvmField
|
||||
val INVALID_VERSION = JvmBytecodeBinaryVersion.create(IntArray(0))
|
||||
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.load.java.components
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ErrorReporter
|
||||
@@ -31,7 +31,7 @@ object RuntimeErrorReporter : ErrorReporter {
|
||||
|
||||
override fun reportIncompatibleAbiVersion(classId: ClassId, filePath: String, actualVersion: BinaryVersion) {
|
||||
throw IllegalStateException("Incompatible ABI version of $classId: $actualVersion " +
|
||||
"(expected version is ${JvmAbi.VERSION})")
|
||||
"(expected version is ${JvmBytecodeBinaryVersion.INSTANCE})")
|
||||
}
|
||||
|
||||
override fun reportCannotInferVisibility(descriptor: CallableMemberDescriptor) {
|
||||
|
||||
@@ -18,10 +18,17 @@ package org.jetbrains.kotlin.builtins
|
||||
|
||||
import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion
|
||||
|
||||
/**
|
||||
* The version of the format in which the .kotlin_builtins file is stored. This version also includes the version
|
||||
* of the core protobuf messages (descriptors.proto).
|
||||
*/
|
||||
class BuiltInsBinaryVersion protected constructor(
|
||||
major: Int, minor: Int, patch: Int, rest: List<Int>
|
||||
) : BinaryVersion(major, minor, patch, rest) {
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE = create(1, 0, 0)
|
||||
|
||||
@JvmStatic
|
||||
fun create(version: IntArray) = create(version, ::BuiltInsBinaryVersion)
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.ProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.builtins.BuiltInsProtoBuf
|
||||
import org.jetbrains.kotlin.serialization.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializedPackageFragment
|
||||
import org.jetbrains.kotlin.serialization.deserialization.NameResolverImpl
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPackageMemberScope
|
||||
@@ -39,11 +38,11 @@ class BuiltinsPackageFragment(
|
||||
val dataInput = DataInputStream(stream)
|
||||
val version = BuiltInsBinaryVersion.create((1..dataInput.readInt()).map { dataInput.readInt() }.toIntArray())
|
||||
|
||||
if (!version.isCompatibleTo(BuiltinsPackageFragment.VERSION)) {
|
||||
if (!version.isCompatibleTo(BuiltInsBinaryVersion.INSTANCE)) {
|
||||
// TODO: report a proper diagnostic
|
||||
throw UnsupportedOperationException(
|
||||
"Kotlin built-in definition format version is not supported: " +
|
||||
"expected ${BuiltinsPackageFragment.VERSION}, actual $version. " +
|
||||
"expected ${BuiltInsBinaryVersion.INSTANCE}, actual $version. " +
|
||||
"Please update Kotlin"
|
||||
)
|
||||
}
|
||||
@@ -71,9 +70,4 @@ class BuiltinsPackageFragment(
|
||||
override fun loadClassNames(packageProto: ProtoBuf.Package): Collection<Name> {
|
||||
return packageProto.getExtension(BuiltInsProtoBuf.className)?.map { id -> nameResolver.getName(id) } ?: listOf()
|
||||
}
|
||||
|
||||
companion object {
|
||||
// Advance this version when the common or builtins-specific binary metadata format is changed
|
||||
val VERSION = BuiltInsBinaryVersion.create(1, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -16,6 +16,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.serialization.deserialization
|
||||
|
||||
/**
|
||||
* Subclasses of this class are used to identify different versions of the binary output of the compiler and their compatibility guarantees.
|
||||
* - Major version should be increased only when the new binary format is neither forward- nor backward compatible.
|
||||
* This shouldn't really ever happen at all.
|
||||
* - Minor version should be increased when the new format is backward compatible,
|
||||
* i.e. the new compiler can process old data, but the old compiler will not be able to process new data.
|
||||
* - Patch version can be increased freely and is only supposed to be used for debugging. Increase the patch version when you
|
||||
* make a change to binaries which is both forward- and backward compatible.
|
||||
*/
|
||||
abstract class BinaryVersion protected constructor(
|
||||
val major: Int,
|
||||
val minor: Int,
|
||||
|
||||
Reference in New Issue
Block a user