Do not fail when deserializing incompatible metadata
Catch all exceptions when deserializing metadata with an incompatible version to prevent the compiler from failing on discovering incompatible classes on the classpath. Note that this is not the perfect solution: any invariant may be broken in the incompatible metadata and it may result in a later exception
This commit is contained in:
@@ -74,6 +74,28 @@ class WrongBytecodeVersionTest : KtUsefulTestCase() {
|
||||
override fun visit(name: String, value: Any) {
|
||||
super.visit(name, transform(name, value) ?: value)
|
||||
}
|
||||
|
||||
override fun visitArray(name: String): AnnotationVisitor {
|
||||
val entries = arrayListOf<String>()
|
||||
val arrayVisitor = { super.visitArray(name) }
|
||||
return object : AnnotationVisitor(Opcodes.ASM5) {
|
||||
override fun visit(name: String?, value: Any) {
|
||||
entries.add(value as String)
|
||||
}
|
||||
|
||||
override fun visitEnd() {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val result = transform(name, entries.toTypedArray()) as Array<String>? ?: entries.toTypedArray()
|
||||
if (result.isEmpty()) return
|
||||
with(arrayVisitor()) {
|
||||
for (value in result) {
|
||||
visit(null, value)
|
||||
}
|
||||
visitEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return superVisitor
|
||||
|
||||
Reference in New Issue
Block a user