mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-29 06:01:03 +00:00
fix: nullable signature members (#10)
This commit will allow "partial" signatures, basically we will be allowed to exclude members to match for the signature
This commit is contained in:
@@ -9,13 +9,12 @@ import net.revanced.patcher.util.ExtraTypes
|
||||
import net.revanced.patcher.util.TestUtil
|
||||
import net.revanced.patcher.writer.ASMWriter.insertAt
|
||||
import net.revanced.patcher.writer.ASMWriter.setAt
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.junit.jupiter.api.assertDoesNotThrow
|
||||
import org.objectweb.asm.Opcodes.*
|
||||
import org.objectweb.asm.Type
|
||||
import org.objectweb.asm.tree.*
|
||||
import java.io.PrintStream
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
internal class PatcherTest {
|
||||
companion object {
|
||||
@@ -149,25 +148,21 @@ internal class PatcherTest {
|
||||
//}
|
||||
|
||||
@Test()
|
||||
fun `should raise an exception because opcodes is empty`() {
|
||||
fun `should not raise an exception if any signature member except the name is missing`() {
|
||||
val sigName = "testMethod"
|
||||
val e = assertThrows<IllegalArgumentException>("Should raise an exception because opcodes is empty") {
|
||||
|
||||
assertDoesNotThrow("Should raise an exception because opcodes is empty") {
|
||||
Patcher(
|
||||
PatcherTest::class.java.getResourceAsStream("/test1.jar")!!,
|
||||
arrayOf(
|
||||
Signature(
|
||||
sigName,
|
||||
Type.VOID_TYPE,
|
||||
ACC_PUBLIC or ACC_STATIC,
|
||||
arrayOf(ExtraTypes.ArrayAny),
|
||||
emptyArray() // this is not allowed for non-search signatures!
|
||||
)
|
||||
)
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null
|
||||
))
|
||||
)
|
||||
}
|
||||
assertEquals(
|
||||
"Opcode list for signature $sigName is empty. This is not allowed for non-search signatures.",
|
||||
e.message
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user