Skip to content

Commit

Permalink
Fail-fast if it's not possible to read @metadata from Kotlin class in… (
Browse files Browse the repository at this point in the history
Kotlin#67)

* 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 <udalov@users.noreply.github.com>
  • Loading branch information
qwwdfsad and udalov authored Aug 17, 2021
1 parent 9ce55a7 commit 31ecef1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/kotlin/api/KotlinMetadataVisibilities.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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()
)
}


Expand Down

0 comments on commit 31ecef1

Please sign in to comment.