jvm-abi-gen: Add test to check the declaration order in interface jars

This commit is contained in:
Steven Schäfer
2021-12-01 13:40:02 +01:00
committed by Alexander Udalov
parent b8625cd233
commit 05695761ec
14 changed files with 69 additions and 18 deletions
@@ -12,7 +12,8 @@ class BytecodeListingTextCollectingVisitor(
val filter: Filter,
val withSignatures: Boolean,
api: Int = Opcodes.API_VERSION,
val withAnnotations: Boolean = true
val withAnnotations: Boolean = true,
val sortDeclarations: Boolean = true,
) : ClassVisitor(api) {
companion object {
@JvmOverloads
@@ -150,7 +151,9 @@ class BytecodeListingTextCollectingVisitor(
append(className)
if (declarationsInsideClass.isNotEmpty()) {
append(" {\n")
for (declaration in declarationsInsideClass.sortedBy { it.text }) {
val orderedDeclarations =
if (sortDeclarations) declarationsInsideClass.sortedBy { it.text } else declarationsInsideClass
for (declaration in orderedDeclarations) {
append(" ").append(declaration.annotations.joinToString("")).append(declaration.text).append("\n")
}
append("}")