fix(script): use default script compiler args
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package jadx.plugins.script
|
||||
|
||||
import jadx.api.JadxArgs
|
||||
import jadx.api.JadxDecompiler
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.io.File
|
||||
import kotlin.system.measureTimeMillis
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toDuration
|
||||
|
||||
class JadxScriptPluginTest {
|
||||
|
||||
@Test
|
||||
fun integrationTest() {
|
||||
val args = JadxArgs()
|
||||
args.inputFiles.run {
|
||||
add(getSampleFile("hello.smali"))
|
||||
add(getSampleFile("test.jadx.kts"))
|
||||
}
|
||||
val elapsed = measureTimeMillis {
|
||||
JadxDecompiler(args).use { jadx ->
|
||||
jadx.load()
|
||||
assertThat(jadx.classes)
|
||||
.hasSize(1)
|
||||
.allMatch { it.name == "HelloJadx" }
|
||||
}
|
||||
}
|
||||
println("Elapsed time: ${elapsed.toDuration(DurationUnit.MILLISECONDS)}")
|
||||
}
|
||||
|
||||
private fun getSampleFile(file: String): File {
|
||||
val resFile = javaClass.classLoader.getResource("samples/$file")
|
||||
return File(resFile!!.toURI())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
.class LHelloWorld;
|
||||
.super Ljava/lang/Object;
|
||||
|
||||
.method public static main([Ljava/lang/String;)V
|
||||
.registers 2
|
||||
sget-object p0, Ljava/lang/System;->out:Ljava/io/PrintStream;
|
||||
const-string v0, "Hello, World"
|
||||
invoke-virtual {p0, v0}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
|
||||
return-void
|
||||
.end method
|
||||
@@ -0,0 +1,20 @@
|
||||
import jadx.api.CommentsLevel
|
||||
|
||||
val jadx = getJadxInstance()
|
||||
jadx.args.commentsLevel = CommentsLevel.NONE
|
||||
jadx.args.isDeobfuscationOn = false
|
||||
jadx.args.renameFlags = emptySet()
|
||||
|
||||
jadx.rename.all { name ->
|
||||
when (name) {
|
||||
"HelloWorld" -> "HelloJadx"
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
jadx.afterLoad {
|
||||
println("Loaded classes: ${jadx.classes.size}")
|
||||
jadx.classes.forEach {
|
||||
println("Class '${it.name}':\n${it.code}")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user