Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/kotlin/api/AsmMetadataLoading.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal fun ClassNode.isEffectivelyPublic(classVisibility: ClassVisibility?) =


private val ClassNode.innerClassNode: InnerClassNode? get() = innerClasses.singleOrNull { it.name == name }
private fun ClassNode.isLocal() = outerMethod != null
private fun ClassNode.isLocal() = outerClass != null // using outerMethod is unreliable, because even for local classes outerMethod can sometimes be null
private fun ClassNode.isInner() = innerClassNode != null
private fun ClassNode.isWhenMappings() = isSynthetic(access) && name.endsWith("\$WhenMappings")
private fun ClassNode.isSyntheticAnnotationClass() = isSynthetic(access) && name.contains("\$annotationImpl\$")
Expand Down
40 changes: 40 additions & 0 deletions src/test/kotlin/tests/PrecompiledCasesTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2016-2025 JetBrains s.r.o.
* Use of this source code is governed by the Apache 2.0 License that can be found in the LICENSE.txt file.
*/

package kotlinx.validation.api.tests

import kotlinx.validation.api.*
import org.junit.*
import org.junit.rules.TestName
import java.io.File
import java.nio.file.Path
import kotlin.io.path.ExperimentalPathApi
import kotlin.io.path.walk

class PrecompiledCasesTest {

companion object {
val baseOutputPath = File("src/test/resources/precompiled")
}

@Rule
@JvmField
val testName = TestName()

@Test fun parcelable() { snapshotAPIAndCompare(testName.methodName) }

@OptIn(ExperimentalPathApi::class)
private fun snapshotAPIAndCompare(testClassRelativePath: String, nonPublicMarkers: Set<String> = emptySet()) {
val testClasses = baseOutputPath.toPath().walk().map(Path::toFile).toList()
check(testClasses.isNotEmpty()) { "No class files are found in path: $baseOutputPath" }

val testClassStreams = testClasses.asSequence().filter { it.name.endsWith(".class") }.map { it.inputStream() }
val classes = testClassStreams.loadApiFromJvmClasses()
val additionalPackages = classes.extractAnnotatedPackages(nonPublicMarkers)
val api = classes.filterOutNonPublic(nonPublicPackages = additionalPackages).filterOutAnnotated(nonPublicMarkers)
val target = baseOutputPath.resolve(testClassRelativePath).resolve(testName.methodName + ".txt")
api.dumpAndCompareWith(target)
}
}
Binary file not shown.
Empty file.