Remove @Throws annotations

We don't need them now we have no more Java code left.
bzip2
Graham 5 years ago
parent 136e43ae82
commit 0b834fb223
  1. 2
      asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt
  2. 5
      asm/src/main/java/dev/openrs2/asm/classpath/Library.kt
  3. 11
      asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt
  4. 3
      decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt
  5. 4
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt
  6. 8
      deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt
  7. 7
      deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt
  8. 2
      deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt
  9. 3
      deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt
  10. 4
      deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt

@ -4,7 +4,6 @@ import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.*
import org.objectweb.asm.tree.analysis.Analyzer
import org.objectweb.asm.tree.analysis.AnalyzerException
import org.objectweb.asm.tree.analysis.BasicInterpreter
import org.objectweb.asm.tree.analysis.BasicValue
@ -100,7 +99,6 @@ fun MethodNode.removeArgument(argIndex: Int) {
}
}
@Throws(AnalyzerException::class)
fun MethodNode.removeDeadCode(owner: String) {
var changed: Boolean
do {

@ -13,7 +13,6 @@ import org.objectweb.asm.commons.Remapper
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.util.CheckClassAdapter
import java.io.ByteArrayInputStream
import java.io.IOException
import java.io.SequenceInputStream
import java.nio.file.Files
import java.nio.file.Path
@ -78,7 +77,6 @@ class Library constructor() : Iterable<ClassNode> {
}
}
@Throws(IOException::class)
fun writeJar(path: Path) {
logger.info { "Writing jar $path" }
@ -94,7 +92,6 @@ class Library constructor() : Iterable<ClassNode> {
}
}
@Throws(IOException::class)
fun writePack(path: Path) {
logger.info { "Writing pack $path" }
@ -123,7 +120,6 @@ class Library constructor() : Iterable<ClassNode> {
private val GZIP_HEADER = byteArrayOf(0x1F, 0x8B.toByte())
@JvmStatic
@Throws(IOException::class)
fun readJar(path: Path): Library {
logger.info { "Reading jar $path" }
@ -150,7 +146,6 @@ class Library constructor() : Iterable<ClassNode> {
}
@JvmStatic
@Throws(IOException::class)
fun readPack(path: Path): Library {
logger.info { "Reading pack $path" }

@ -6,10 +6,8 @@ import dev.openrs2.asm.hasCode
import org.objectweb.asm.tree.ClassNode
import org.objectweb.asm.tree.FieldNode
import org.objectweb.asm.tree.MethodNode
import org.objectweb.asm.tree.analysis.AnalyzerException
abstract class Transformer {
@Throws(AnalyzerException::class)
fun transform(classPath: ClassPath) {
preTransform(classPath)
@ -43,22 +41,18 @@ abstract class Transformer {
postTransform(classPath)
}
@Throws(AnalyzerException::class)
protected open fun preTransform(classPath: ClassPath) {
// empty
}
@Throws(AnalyzerException::class)
protected open fun prePass(classPath: ClassPath) {
// empty
}
@Throws(AnalyzerException::class)
protected open fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean {
return false
}
@Throws(AnalyzerException::class)
protected open fun transformField(
classPath: ClassPath,
library: Library,
@ -68,7 +62,6 @@ abstract class Transformer {
return false
}
@Throws(AnalyzerException::class)
protected open fun preTransformMethod(
classPath: ClassPath,
library: Library,
@ -78,7 +71,6 @@ abstract class Transformer {
return false
}
@Throws(AnalyzerException::class)
protected open fun transformCode(
classPath: ClassPath,
library: Library,
@ -88,7 +80,6 @@ abstract class Transformer {
return false
}
@Throws(AnalyzerException::class)
protected open fun postTransformMethod(
classPath: ClassPath,
library: Library,
@ -98,12 +89,10 @@ abstract class Transformer {
return false
}
@Throws(AnalyzerException::class)
protected open fun postPass(classPath: ClassPath) {
// empty
}
@Throws(AnalyzerException::class)
protected open fun postTransform(classPath: ClassPath) {
// empty
}

@ -4,7 +4,6 @@ import com.google.common.io.ByteStreams
import org.jetbrains.java.decompiler.main.extern.IBytecodeProvider
import org.jetbrains.java.decompiler.main.extern.IResultSaver
import java.io.Closeable
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Path
import java.util.jar.JarFile
@ -13,7 +12,6 @@ import java.util.jar.Manifest
class DecompilerIo(private val destination: (String) -> Path) : IBytecodeProvider, IResultSaver, Closeable {
private val inputJars = mutableMapOf<String, JarFile>()
@Throws(IOException::class)
override fun getBytecode(externalPath: String, internalPath: String?): ByteArray {
if (internalPath == null) {
throw UnsupportedOperationException()
@ -76,7 +74,6 @@ class DecompilerIo(private val destination: (String) -> Path) : IBytecodeProvide
// ignore
}
@Throws(IOException::class)
override fun close() {
for (jar in inputJars.values) {
jar.close()

@ -10,14 +10,11 @@ import dev.openrs2.bundler.Bundler
import dev.openrs2.deob.SignedClassUtils.move
import dev.openrs2.deob.remap.PrefixRemapper.create
import dev.openrs2.deob.transform.*
import org.objectweb.asm.tree.analysis.AnalyzerException
import java.io.IOException
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
class Deobfuscator(private val input: Path, private val output: Path) {
@Throws(IOException::class, AnalyzerException::class)
fun run() {
// read input jars/packs
logger.info { "Reading input jars" }
@ -146,7 +143,6 @@ class Deobfuscator(private val input: Path, private val output: Path) {
AccessTransformer()
)
@Throws(IOException::class, AnalyzerException::class)
@JvmStatic
fun main(args: Array<String>) {
val deobfuscator = Deobfuscator(Paths.get("nonfree/code"), Paths.get("nonfree/code/deob"))

@ -4,7 +4,6 @@ import dev.openrs2.asm.intConstant
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.AbstractInsnNode
import org.objectweb.asm.tree.analysis.AnalyzerException
import org.objectweb.asm.tree.analysis.BasicInterpreter
import org.objectweb.asm.tree.analysis.Interpreter
@ -16,7 +15,6 @@ class ConstSourceInterpreter : Interpreter<ConstSourceValue>(Opcodes.ASM7) {
return ConstSourceValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun newOperation(insn: AbstractInsnNode): ConstSourceValue {
val basicValue = basicInterpreter.newOperation(insn)
return if (insn.intConstant != null) {
@ -26,19 +24,16 @@ class ConstSourceInterpreter : Interpreter<ConstSourceValue>(Opcodes.ASM7) {
}
}
@Throws(AnalyzerException::class)
override fun copyOperation(insn: AbstractInsnNode, value: ConstSourceValue): ConstSourceValue {
val basicValue = basicInterpreter.copyOperation(insn, value.basicValue)
return ConstSourceValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun unaryOperation(insn: AbstractInsnNode, value: ConstSourceValue): ConstSourceValue? {
val basicValue = basicInterpreter.unaryOperation(insn, value.basicValue) ?: return null
return ConstSourceValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun binaryOperation(
insn: AbstractInsnNode,
value1: ConstSourceValue,
@ -49,7 +44,6 @@ class ConstSourceInterpreter : Interpreter<ConstSourceValue>(Opcodes.ASM7) {
return ConstSourceValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun ternaryOperation(
insn: AbstractInsnNode,
value1: ConstSourceValue,
@ -65,7 +59,6 @@ class ConstSourceInterpreter : Interpreter<ConstSourceValue>(Opcodes.ASM7) {
return ConstSourceValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun naryOperation(
insn: AbstractInsnNode,
values: List<ConstSourceValue>
@ -75,7 +68,6 @@ class ConstSourceInterpreter : Interpreter<ConstSourceValue>(Opcodes.ASM7) {
return ConstSourceValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun returnOperation(insn: AbstractInsnNode, value: ConstSourceValue, expected: ConstSourceValue) {
basicInterpreter.returnOperation(insn, value.basicValue, expected.basicValue)
}

@ -5,7 +5,6 @@ import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.AbstractInsnNode
import org.objectweb.asm.tree.IincInsnNode
import org.objectweb.asm.tree.analysis.AnalyzerException
import org.objectweb.asm.tree.analysis.BasicInterpreter
import org.objectweb.asm.tree.analysis.Interpreter
@ -36,7 +35,6 @@ class IntInterpreter(private val parameters: Array<Set<Int>?>?) : Interpreter<In
return IntValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun newOperation(insn: AbstractInsnNode): IntValue {
val basicValue = basicInterpreter.newOperation(insn)
val v = insn.intConstant
@ -51,7 +49,6 @@ class IntInterpreter(private val parameters: Array<Set<Int>?>?) : Interpreter<In
return value
}
@Throws(AnalyzerException::class)
override fun unaryOperation(insn: AbstractInsnNode, value: IntValue): IntValue? {
val basicValue = basicInterpreter.unaryOperation(insn, value.basicValue) ?: return null
@ -74,7 +71,6 @@ class IntInterpreter(private val parameters: Array<Set<Int>?>?) : Interpreter<In
return IntValue.Constant(basicValue, set)
}
@Throws(AnalyzerException::class)
override fun binaryOperation(insn: AbstractInsnNode, value1: IntValue, value2: IntValue): IntValue? {
val basicValue = basicInterpreter.binaryOperation(insn, value1.basicValue, value2.basicValue) ?: return null
@ -115,7 +111,6 @@ class IntInterpreter(private val parameters: Array<Set<Int>?>?) : Interpreter<In
return IntValue.Constant(basicValue, set)
}
@Throws(AnalyzerException::class)
override fun ternaryOperation(
insn: AbstractInsnNode,
value1: IntValue,
@ -128,14 +123,12 @@ class IntInterpreter(private val parameters: Array<Set<Int>?>?) : Interpreter<In
return IntValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun naryOperation(insn: AbstractInsnNode, values: List<IntValue>): IntValue? {
val args = values.map { it.basicValue }.toList()
val basicValue = basicInterpreter.naryOperation(insn, args) ?: return null
return IntValue.Unknown(basicValue)
}
@Throws(AnalyzerException::class)
override fun returnOperation(insn: AbstractInsnNode, value: IntValue, expected: IntValue) {
basicInterpreter.returnOperation(insn, value.basicValue, expected.basicValue)
}

@ -16,7 +16,6 @@ import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.*
import org.objectweb.asm.tree.analysis.Analyzer
import org.objectweb.asm.tree.analysis.AnalyzerException
class DummyArgTransformer : Transformer() {
private data class ConditionalCall(
@ -142,7 +141,6 @@ class DummyArgTransformer : Transformer() {
conditionalCalls.clear()
}
@Throws(AnalyzerException::class)
override fun transformCode(
classPath: ClassPath,
library: Library,

@ -10,12 +10,10 @@ import dev.openrs2.asm.removeDeadCode
import dev.openrs2.asm.transform.Transformer
import org.objectweb.asm.Opcodes
import org.objectweb.asm.tree.*
import org.objectweb.asm.tree.analysis.AnalyzerException
class ResetTransformer : Transformer() {
private val resetMethods = mutableSetOf<MemberRef>()
@Throws(AnalyzerException::class)
override fun preTransform(classPath: ClassPath) {
resetMethods.clear()
@ -94,7 +92,6 @@ class ResetTransformer : Transformer() {
return null
}
@Throws(AnalyzerException::class)
private fun findResetMethods(resetMethods: MutableSet<MemberRef>, clazz: ClassNode, method: MethodNode) {
method.removeDeadCode(clazz.name)

@ -16,14 +16,12 @@ import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import org.objectweb.asm.tree.*
import org.objectweb.asm.tree.analysis.Analyzer
import org.objectweb.asm.tree.analysis.AnalyzerException
class UnusedArgTransformer : Transformer() {
private val retainedArgs = mutableSetOf<ArgRef>()
private lateinit var inheritedMethodSets: DisjointSet<MemberRef>
private var deletedArgs = 0
@Throws(AnalyzerException::class)
override fun preTransform(classPath: ClassPath) {
retainedArgs.clear()
inheritedMethodSets = classPath.createInheritedMethodSets()
@ -40,7 +38,6 @@ class UnusedArgTransformer : Transformer() {
}
}
@Throws(AnalyzerException::class)
private fun populateRetainedArgs(classPath: ClassPath, clazz: ClassNode, method: MethodNode) {
val partition = inheritedMethodSets[MemberRef(clazz, method)]!!
val localToArgMap = createLocalToArgMap(method)
@ -85,7 +82,6 @@ class UnusedArgTransformer : Transformer() {
}
}
@Throws(AnalyzerException::class)
override fun preTransformMethod(
classPath: ClassPath,
library: Library,

Loading…
Cancel
Save