From 31ecef130945dc9641aaffb07caba9a608336123 Mon Sep 17 00:00:00 2001 From: Vsevolod Tolstopyatov Date: Tue, 17 Aug 2021 19:10:55 +0300 Subject: [PATCH] =?UTF-8?q?Fail-fast=20if=20it's=20not=20possible=20to=20r?= =?UTF-8?q?ead=20@Metadata=20from=20Kotlin=20class=20in=E2=80=A6=20(#67)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fail-fast if it's not possible to read @Metadata from Kotlin class instead of producing incorrect visibilities and dumps Co-authored-by: Alexander Udalov --- src/main/kotlin/api/KotlinMetadataVisibilities.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/kotlin/api/KotlinMetadataVisibilities.kt b/src/main/kotlin/api/KotlinMetadataVisibilities.kt index 07a07b9e..3971d662 100644 --- a/src/main/kotlin/api/KotlinMetadataVisibilities.kt +++ b/src/main/kotlin/api/KotlinMetadataVisibilities.kt @@ -7,6 +7,7 @@ package kotlinx.validation.api import kotlinx.metadata.* import kotlinx.metadata.jvm.* +import kotlinx.metadata.jvm.KotlinClassHeader.Companion.COMPATIBLE_METADATA_VERSION import org.objectweb.asm.tree.ClassNode class ClassVisibility( @@ -59,6 +60,14 @@ val ClassNode.kotlinMetadata: KotlinClassMetadata? ) } return KotlinClassMetadata.read(header) + ?: error( + """ + Incompatible version of Kotlin metadata. + Maximal supported Kotlin metadata version: ${COMPATIBLE_METADATA_VERSION.joinToString(".")}, + $name Kotlin metadata version: ${header.metadataVersion.joinToString(".")}. + As a workaround, it is possible to manually update 'kotlinx-metadata-jvm' version in your project. + """.trimIndent() + ) }