Skip to content

Commit 71b6250

Browse files
committed
Merge branch 'master' into develop
2 parents a742b29 + 9112e78 commit 71b6250

File tree

5 files changed

+55
-1
lines changed

5 files changed

+55
-1
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
[![License](https://img.shields.io/github/license/Kotlin/binary-compatibility-validator)](LICENSE.TXT)
55
[![KDoc link](https://img.shields.io/badge/API_reference-KDoc-blue)](https://kotlin.github.io/binary-compatibility-validator/)
66

7+
# Support for this plugin has been discontinued
8+
9+
> [!WARNING]
10+
> The development of a separate binary compatibility validator Gradle plugin has been discontinued,
11+
> and all its functionality will be moved to Kotlin Gradle Plugin starting from the [`2.2.0` release](https://kotlinlang.org/docs/whatsnew22.html#binary-compatibility-validation-included-in-kotlin-gradle-plugin).
12+
>
13+
> As part of the migration, the code of the current plugin has been migrated to [the Kotlin repository](https://github.com/JetBrains/kotlin/tree/master/libraries/tools/abi-validation),
14+
> as well as issues migrated to [the Kotlin project in YouTrack](https://youtrack.jetbrains.com/issues/KT?q=subsystems:%20%7BTools.%20BCV%7D,%20%7BTools.%20Gradle.%20BCV%7D).
15+
>
16+
> This plugin is frozen from changes, no new features or minor bugfixes will be added to it.
17+
>
18+
> The functionality of working with the ABI in Kotlin Gradle Plugin is in an experimental state now,
19+
> so it is recommended to continue using this plugin in production projects until KGP API stabilization.
20+
721
# Binary compatibility validator
822

923
The tool allows dumping binary API of a JVM part of a Kotlin library that is public in the sense of Kotlin visibilities and ensures that the public binary API wasn't changed in a way that makes this change binary incompatible.

src/main/kotlin/api/AsmMetadataLoading.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal fun ClassNode.isEffectivelyPublic(classVisibility: ClassVisibility?) =
3939

4040

4141
private val ClassNode.innerClassNode: InnerClassNode? get() = innerClasses.singleOrNull { it.name == name }
42-
private fun ClassNode.isLocal() = outerMethod != null
42+
private fun ClassNode.isLocal() = outerClass != null // using outerMethod is unreliable, because even for local classes outerMethod can sometimes be null
4343
private fun ClassNode.isInner() = innerClassNode != null
4444
private fun ClassNode.isWhenMappings() = isSynthetic(access) && name.endsWith("\$WhenMappings")
4545
private fun ClassNode.isSyntheticAnnotationClass() = isSynthetic(access) && name.contains("\$annotationImpl\$")
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2016-2025 JetBrains s.r.o.
3+
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
4+
*/
5+
6+
package kotlinx.validation.api.tests
7+
8+
import kotlinx.validation.api.*
9+
import org.junit.*
10+
import org.junit.rules.TestName
11+
import java.io.File
12+
import java.nio.file.Path
13+
import kotlin.io.path.ExperimentalPathApi
14+
import kotlin.io.path.walk
15+
16+
class PrecompiledCasesTest {
17+
18+
companion object {
19+
val baseOutputPath = File("src/test/resources/precompiled")
20+
}
21+
22+
@Rule
23+
@JvmField
24+
val testName = TestName()
25+
26+
@Test fun parcelable() { snapshotAPIAndCompare(testName.methodName) }
27+
28+
@OptIn(ExperimentalPathApi::class)
29+
private fun snapshotAPIAndCompare(testClassRelativePath: String, nonPublicMarkers: Set<String> = emptySet()) {
30+
val testClasses = baseOutputPath.toPath().walk().map(Path::toFile).toList()
31+
check(testClasses.isNotEmpty()) { "No class files are found in path: $baseOutputPath" }
32+
33+
val testClassStreams = testClasses.asSequence().filter { it.name.endsWith(".class") }.map { it.inputStream() }
34+
val classes = testClassStreams.loadApiFromJvmClasses()
35+
val additionalPackages = classes.extractAnnotatedPackages(nonPublicMarkers)
36+
val api = classes.filterOutNonPublic(nonPublicPackages = additionalPackages).filterOutAnnotated(nonPublicMarkers)
37+
val target = baseOutputPath.resolve(testClassRelativePath).resolve(testName.methodName + ".txt")
38+
api.dumpAndCompareWith(target)
39+
}
40+
}
Binary file not shown.

src/test/resources/precompiled/parcelable/parcelable.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)