From 1d5f1f83be1f4eb78381887cd59f1649f1ed6d71 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Tue, 5 Dec 2023 00:54:54 +0100 Subject: [PATCH] fix: Use correct class loader to load resources --- src/main/kotlin/app/revanced/util/ResourceUtils.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/app/revanced/util/ResourceUtils.kt b/src/main/kotlin/app/revanced/util/ResourceUtils.kt index e3ccc7bfb..d7aef39b6 100644 --- a/src/main/kotlin/app/revanced/util/ResourceUtils.kt +++ b/src/main/kotlin/app/revanced/util/ResourceUtils.kt @@ -8,6 +8,8 @@ import org.w3c.dom.Node import java.nio.file.Files import java.nio.file.StandardCopyOption +private val classLoader = object {}.javaClass.classLoader + /** * Recursively traverse the DOM tree starting from the given root node. * @@ -45,7 +47,6 @@ fun ResourceContext.mergeStrings(host: String) { * @param resources The resources to copy. */ fun ResourceContext.copyResources(sourceResourceDirectory: String, vararg resources: ResourceGroup) { - val classLoader = javaClass.classLoader val targetResourceDirectory = this["res"] for (resourceGroup in resources) { @@ -77,7 +78,7 @@ fun ResourceContext.iterateXmlNodeChildren( targetTag: String, callback: (node: Node) -> Unit ) = - xmlEditor[javaClass.classLoader.getResourceAsStream(resource)!!].use { + xmlEditor[classLoader.getResourceAsStream(resource)!!].use { val stringsNode = it.file.getElementsByTagName(targetTag).item(0).childNodes for (i in 1 until stringsNode.length - 1) callback(stringsNode.item(i)) }