From a306561b55ac848792046378f582a036f7ffab03 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Fri, 2 Dec 2022 03:30:35 +0100 Subject: [PATCH] feat: sort patches in lexicographical order Closes #125 --- .../kotlin/app/revanced/patcher/util/patch/PatchBundle.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt b/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt index 0c07255..f7459d9 100644 --- a/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt +++ b/src/main/kotlin/app/revanced/patcher/util/patch/PatchBundle.kt @@ -3,6 +3,7 @@ package app.revanced.patcher.util.patch import app.revanced.patcher.data.Context +import app.revanced.patcher.extensions.PatchExtensions.patchName import app.revanced.patcher.patch.Patch import org.jf.dexlib2.DexFileFactory import java.io.File @@ -16,12 +17,12 @@ import java.util.jar.JarFile */ sealed class PatchBundle(path: String) : File(path) { internal fun loadPatches(classLoader: ClassLoader, classNames: Iterator) = buildList { - for (className in classNames) { + classNames.forEach { className -> val clazz = classLoader.loadClass(className) - if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) continue + if (!clazz.isAnnotationPresent(app.revanced.patcher.patch.annotations.Patch::class.java)) return@forEach @Suppress("UNCHECKED_CAST") this.add(clazz as Class>) } - } + }.sortedBy { it.patchName } /** * A patch bundle of type [Jar].