From 0b834fb2239e10d8e997541d07b946aed5b9c6d9 Mon Sep 17 00:00:00 2001 From: Graham Date: Thu, 26 Dec 2019 20:49:40 +0000 Subject: [PATCH] Remove @Throws annotations We don't need them now we have no more Java code left. --- asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt | 2 -- .../main/java/dev/openrs2/asm/classpath/Library.kt | 5 ----- .../java/dev/openrs2/asm/transform/Transformer.kt | 11 ----------- .../main/java/dev/openrs2/decompiler/DecompilerIo.kt | 3 --- deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt | 4 ---- .../openrs2/deob/analysis/ConstSourceInterpreter.kt | 8 -------- .../java/dev/openrs2/deob/analysis/IntInterpreter.kt | 7 ------- .../dev/openrs2/deob/transform/DummyArgTransformer.kt | 2 -- .../dev/openrs2/deob/transform/ResetTransformer.kt | 3 --- .../openrs2/deob/transform/UnusedArgTransformer.kt | 4 ---- 10 files changed, 49 deletions(-) diff --git a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt index f83c50e2..df9cc2ce 100644 --- a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.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 { diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt b/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt index 41c4e4c5..3e05ea3a 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt @@ -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 { } } - @Throws(IOException::class) fun writeJar(path: Path) { logger.info { "Writing jar $path" } @@ -94,7 +92,6 @@ class Library constructor() : Iterable { } } - @Throws(IOException::class) fun writePack(path: Path) { logger.info { "Writing pack $path" } @@ -123,7 +120,6 @@ class Library constructor() : Iterable { 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 { } @JvmStatic - @Throws(IOException::class) fun readPack(path: Path): Library { logger.info { "Reading pack $path" } diff --git a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt index 83ea4193..7c81379a 100644 --- a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt +++ b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt @@ -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 } diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt b/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt index d0c6c350..75b13282 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt @@ -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() - @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() diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt index 94f59fb9..88fde2d3 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt @@ -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) { val deobfuscator = Deobfuscator(Paths.get("nonfree/code"), Paths.get("nonfree/code/deob")) diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt b/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt index 56c3f10c..62c54cc9 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt @@ -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(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(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(Opcodes.ASM7) { return ConstSourceValue.Unknown(basicValue) } - @Throws(AnalyzerException::class) override fun ternaryOperation( insn: AbstractInsnNode, value1: ConstSourceValue, @@ -65,7 +59,6 @@ class ConstSourceInterpreter : Interpreter(Opcodes.ASM7) { return ConstSourceValue.Unknown(basicValue) } - @Throws(AnalyzerException::class) override fun naryOperation( insn: AbstractInsnNode, values: List @@ -75,7 +68,6 @@ class ConstSourceInterpreter : Interpreter(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) } diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt index 1b38910f..cdc7ac3b 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt @@ -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?>?) : Interpreter?>?) : Interpreter?>?) : Interpreter?>?) : Interpreter?>?) : Interpreter): 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) } diff --git a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt index 3d877472..694e2ba1 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/DummyArgTransformer.kt @@ -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, diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt index cf1e9a5a..226630a5 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt @@ -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() - @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, clazz: ClassNode, method: MethodNode) { method.removeDeadCode(clazz.name) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt index c1709e79..c1b24953 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt @@ -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() private lateinit var inheritedMethodSets: DisjointSet 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,