diff --git a/all/src/main/java/dev/openrs2/Command.kt b/all/src/main/java/dev/openrs2/Command.kt index 2de0059562..30316d7a77 100644 --- a/all/src/main/java/dev/openrs2/Command.kt +++ b/all/src/main/java/dev/openrs2/Command.kt @@ -10,9 +10,9 @@ import dev.openrs2.deob.DeobfuscateCommand import dev.openrs2.deob.ast.DeobfuscateAstCommand import dev.openrs2.game.GameCommand -fun main(args: Array) = Command().main(args) +public fun main(args: Array): Unit = Command().main(args) -class Command : NoOpCliktCommand(name = "openrs2") { +public class Command : NoOpCliktCommand(name = "openrs2") { init { subcommands( BundleCommand(), diff --git a/asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt b/asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt index 1dafbfdeee..cfd6f29c6b 100644 --- a/asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt +++ b/asm/src/main/java/dev/openrs2/asm/AsmJacksonModule.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule import javax.inject.Singleton @Singleton -class AsmJacksonModule : SimpleModule() { +public class AsmJacksonModule : SimpleModule() { init { addDeserializer(MemberRef::class.java, MemberRefDeserializer) addKeyDeserializer(MemberRef::class.java, MemberRefKeyDeserializer) diff --git a/asm/src/main/java/dev/openrs2/asm/AsmModule.kt b/asm/src/main/java/dev/openrs2/asm/AsmModule.kt index f28b730988..dc16b3a84b 100644 --- a/asm/src/main/java/dev/openrs2/asm/AsmModule.kt +++ b/asm/src/main/java/dev/openrs2/asm/AsmModule.kt @@ -5,7 +5,7 @@ import com.google.inject.AbstractModule import com.google.inject.multibindings.Multibinder import dev.openrs2.yaml.YamlModule -object AsmModule : AbstractModule() { +public object AsmModule : AbstractModule() { override fun configure() { install(YamlModule) diff --git a/asm/src/main/java/dev/openrs2/asm/ClassForNameUtils.kt b/asm/src/main/java/dev/openrs2/asm/ClassForNameUtils.kt index 4fd54d863e..7fc3cd7b9f 100644 --- a/asm/src/main/java/dev/openrs2/asm/ClassForNameUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/ClassForNameUtils.kt @@ -6,7 +6,7 @@ import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode -object ClassForNameUtils { +public object ClassForNameUtils { private val INVOKE_MATCHER = InsnMatcher.compile("LDC INVOKESTATIC") private fun isClassForName(match: List): Boolean { @@ -31,11 +31,11 @@ object ClassForNameUtils { return (ldc.cst as String).toInternalClassName() } - fun findClassNames(method: MethodNode): Sequence { + public fun findClassNames(method: MethodNode): Sequence { return findLdcInsns(method).map(::internalName) } - fun remap(remapper: Remapper, method: MethodNode) { + public fun remap(remapper: Remapper, method: MethodNode) { for (ldc in findLdcInsns(method)) { val name = remapper.mapType(internalName(ldc)) if (name != null) { diff --git a/asm/src/main/java/dev/openrs2/asm/ClassNameExtensions.kt b/asm/src/main/java/dev/openrs2/asm/ClassNameExtensions.kt index 2df1840e7d..ce3440f5b2 100644 --- a/asm/src/main/java/dev/openrs2/asm/ClassNameExtensions.kt +++ b/asm/src/main/java/dev/openrs2/asm/ClassNameExtensions.kt @@ -1,9 +1,9 @@ package dev.openrs2.asm -fun String.toBinaryClassName(): String { +public fun String.toBinaryClassName(): String { return replace('/', '.') } -fun String.toInternalClassName(): String { +public fun String.toInternalClassName(): String { return replace('.', '/') } diff --git a/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt b/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt index 63a2920896..22f498aff6 100644 --- a/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt +++ b/asm/src/main/java/dev/openrs2/asm/ClassNodeRemapper.kt @@ -18,7 +18,7 @@ import org.objectweb.asm.tree.ParameterNode import org.objectweb.asm.tree.TryCatchBlockNode import org.objectweb.asm.tree.TypeInsnNode -fun ClassNode.remap(remapper: ExtendedRemapper) { +public fun ClassNode.remap(remapper: ExtendedRemapper) { val originalName = name name = remapper.mapType(originalName) signature = remapper.mapSignature(signature, false) @@ -46,20 +46,20 @@ fun ClassNode.remap(remapper: ExtendedRemapper) { } } -fun InnerClassNode.remap(remapper: Remapper) { +public fun InnerClassNode.remap(remapper: Remapper) { name = remapper.mapType(name) outerName = remapper.mapType(outerName) innerName = remapper.mapType(innerName) } -fun FieldNode.remap(remapper: ExtendedRemapper, owner: String) { +public fun FieldNode.remap(remapper: ExtendedRemapper, owner: String) { name = remapper.mapFieldName(owner, name, desc) desc = remapper.mapDesc(desc) signature = remapper.mapSignature(signature, true) value = remapper.mapValue(value) } -fun MethodNode.remap(remapper: ExtendedRemapper, owner: String) { +public fun MethodNode.remap(remapper: ExtendedRemapper, owner: String) { if (parameters == null) { parameters = List(Type.getArgumentTypes(desc).size) { ParameterNode(null, 0) } } @@ -86,15 +86,21 @@ fun MethodNode.remap(remapper: ExtendedRemapper, owner: String) { } } -fun ParameterNode.remap(remapper: ExtendedRemapper, owner: String, methodName: String, desc: String, index: Int) { +public fun ParameterNode.remap( + remapper: ExtendedRemapper, + owner: String, + methodName: String, + desc: String, + index: Int +) { name = remapper.mapArgumentName(owner, methodName, desc, index, name) } -fun TryCatchBlockNode.remap(remapper: Remapper) { +public fun TryCatchBlockNode.remap(remapper: Remapper) { type = remapper.mapType(type) } -fun AbstractInsnNode.remap(remapper: ExtendedRemapper) { +public fun AbstractInsnNode.remap(remapper: ExtendedRemapper) { when (this) { is FrameNode -> throw UnsupportedOperationException("SKIP_FRAMES and COMPUTE_FRAMES must be used") is FieldInsnNode -> { diff --git a/asm/src/main/java/dev/openrs2/asm/ClassVersionUtils.kt b/asm/src/main/java/dev/openrs2/asm/ClassVersionUtils.kt index 5a126fde72..beec586f0a 100644 --- a/asm/src/main/java/dev/openrs2/asm/ClassVersionUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/ClassVersionUtils.kt @@ -1,15 +1,15 @@ package dev.openrs2.asm -object ClassVersionUtils { +public object ClassVersionUtils { private fun swapWords(v: Int): Int { return (v shl 16) or (v ushr 16) } - fun gte(v1: Int, v2: Int): Boolean { + public fun gte(v1: Int, v2: Int): Boolean { return swapWords(v1) >= swapWords(v2) } - fun max(v1: Int, v2: Int): Int { + public fun max(v1: Int, v2: Int): Int { return if (gte(v1, v2)) { v1 } else { diff --git a/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt b/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt index 7718ff3072..8d294ed93b 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/InsnListUtils.kt @@ -5,7 +5,7 @@ import org.objectweb.asm.tree.InsnList private val ANY_INSN = { _: AbstractInsnNode -> true } -fun getExpression( +public fun getExpression( last: AbstractInsnNode, filter: (AbstractInsnNode) -> Boolean = ANY_INSN ): List? { @@ -31,7 +31,7 @@ fun getExpression( return null } -fun InsnList.replaceExpression( +public fun InsnList.replaceExpression( last: AbstractInsnNode, replacement: AbstractInsnNode, filter: (AbstractInsnNode) -> Boolean = ANY_INSN @@ -42,7 +42,7 @@ fun InsnList.replaceExpression( return true } -fun InsnList.deleteExpression( +public fun InsnList.deleteExpression( last: AbstractInsnNode, filter: (AbstractInsnNode) -> Boolean = ANY_INSN ): Boolean { diff --git a/asm/src/main/java/dev/openrs2/asm/InsnMatcher.kt b/asm/src/main/java/dev/openrs2/asm/InsnMatcher.kt index 61a94e498a..2db889c54e 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnMatcher.kt +++ b/asm/src/main/java/dev/openrs2/asm/InsnMatcher.kt @@ -6,12 +6,12 @@ import org.objectweb.asm.tree.InsnList import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.util.Printer -class InsnMatcher private constructor(private val regex: Regex) { - fun match(method: MethodNode): Sequence> { +public class InsnMatcher private constructor(private val regex: Regex) { + public fun match(method: MethodNode): Sequence> { return match(method.instructions) } - fun match(list: InsnList): Sequence> { + public fun match(list: InsnList): Sequence> { val insns = ArrayList(list.size()) val builder = StringBuilder(list.size()) @@ -27,7 +27,7 @@ class InsnMatcher private constructor(private val regex: Regex) { } } - companion object { + public companion object { private const val PRIVATE_USE_AREA = 0xE000 private val OPCODE_GROUPS = mapOf( "InsnNode" to intArrayOf( @@ -260,7 +260,7 @@ class InsnMatcher private constructor(private val regex: Regex) { throw IllegalArgumentException("$opcode is not a valid opcode or opcode group") } - fun compile(regex: String): InsnMatcher { + public fun compile(regex: String): InsnMatcher { val pattern = StringBuilder() val opcode = StringBuilder() diff --git a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt index 0b6c0fe8e1..e9ef712051 100644 --- a/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/InsnNodeUtils.kt @@ -200,7 +200,7 @@ private val THROW_RETURN_OPCODES = listOf( Opcodes.ATHROW ) -val AbstractInsnNode.nextReal: AbstractInsnNode? +public val AbstractInsnNode.nextReal: AbstractInsnNode? get() { var insn = next while (insn != null && insn.opcode == -1) { @@ -209,7 +209,7 @@ val AbstractInsnNode.nextReal: AbstractInsnNode? return insn } -val AbstractInsnNode.previousReal: AbstractInsnNode? +public val AbstractInsnNode.previousReal: AbstractInsnNode? get() { var insn = previous while (insn != null && insn.opcode == -1) { @@ -218,7 +218,7 @@ val AbstractInsnNode.previousReal: AbstractInsnNode? return insn } -val AbstractInsnNode.nextVirtual: AbstractInsnNode? +public val AbstractInsnNode.nextVirtual: AbstractInsnNode? get() { var insn = next while (insn != null && insn.opcode != -1) { @@ -227,7 +227,7 @@ val AbstractInsnNode.nextVirtual: AbstractInsnNode? return insn } -val AbstractInsnNode.previousVirtual: AbstractInsnNode? +public val AbstractInsnNode.previousVirtual: AbstractInsnNode? get() { var insn = previous while (insn != null && insn.opcode != -1) { @@ -236,7 +236,7 @@ val AbstractInsnNode.previousVirtual: AbstractInsnNode? return insn } -val AbstractInsnNode.intConstant: Int? +public val AbstractInsnNode.intConstant: Int? get() = when (this) { is IntInsnNode -> { if (opcode == Opcodes.BIPUSH || opcode == Opcodes.SIPUSH) { @@ -265,7 +265,7 @@ val AbstractInsnNode.intConstant: Int? } } -val AbstractInsnNode.isSequential: Boolean +public val AbstractInsnNode.isSequential: Boolean get() = when (this) { is LabelNode -> false is JumpInsnNode -> false @@ -274,14 +274,14 @@ val AbstractInsnNode.isSequential: Boolean else -> opcode !in THROW_RETURN_OPCODES } -val AbstractInsnNode.isPure: Boolean +public val AbstractInsnNode.isPure: Boolean get() = when (opcode) { in PURE_OPCODES -> true in IMPURE_OPCODES -> false else -> throw IllegalArgumentException() } -fun Int.toAbstractInsnNode(): AbstractInsnNode = when (this) { +public fun Int.toAbstractInsnNode(): AbstractInsnNode = when (this) { -1 -> InsnNode(Opcodes.ICONST_M1) 0 -> InsnNode(Opcodes.ICONST_0) 1 -> InsnNode(Opcodes.ICONST_1) @@ -294,7 +294,7 @@ fun Int.toAbstractInsnNode(): AbstractInsnNode = when (this) { else -> LdcInsnNode(this) } -fun AbstractInsnNode.toPrettyString(): String { +public fun AbstractInsnNode.toPrettyString(): String { val printer = Textifier() val visitor = TraceMethodVisitor(printer) @@ -308,7 +308,7 @@ fun AbstractInsnNode.toPrettyString(): String { } } -fun TryCatchBlockNode.isBodyEmpty(): Boolean { +public fun TryCatchBlockNode.isBodyEmpty(): Boolean { var current = start.next while (true) { diff --git a/asm/src/main/java/dev/openrs2/asm/MemberDesc.kt b/asm/src/main/java/dev/openrs2/asm/MemberDesc.kt index 4ee9f8dcb7..0ec7c092ef 100644 --- a/asm/src/main/java/dev/openrs2/asm/MemberDesc.kt +++ b/asm/src/main/java/dev/openrs2/asm/MemberDesc.kt @@ -5,12 +5,12 @@ import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode -data class MemberDesc(val name: String, val desc: String) { - constructor(field: FieldNode) : this(field.name, field.desc) - constructor(method: MethodNode) : this(method.name, method.desc) - constructor(fieldInsn: FieldInsnNode) : this(fieldInsn.name, fieldInsn.desc) - constructor(methodInsn: MethodInsnNode) : this(methodInsn.name, methodInsn.desc) - constructor(memberRef: MemberRef) : this(memberRef.name, memberRef.desc) +public data class MemberDesc(val name: String, val desc: String) { + public constructor(field: FieldNode) : this(field.name, field.desc) + public constructor(method: MethodNode) : this(method.name, method.desc) + public constructor(fieldInsn: FieldInsnNode) : this(fieldInsn.name, fieldInsn.desc) + public constructor(methodInsn: MethodInsnNode) : this(methodInsn.name, methodInsn.desc) + public constructor(memberRef: MemberRef) : this(memberRef.name, memberRef.desc) override fun toString(): String { return "$name $desc" diff --git a/asm/src/main/java/dev/openrs2/asm/MemberRef.kt b/asm/src/main/java/dev/openrs2/asm/MemberRef.kt index 0a40e5ba8b..20693528a9 100644 --- a/asm/src/main/java/dev/openrs2/asm/MemberRef.kt +++ b/asm/src/main/java/dev/openrs2/asm/MemberRef.kt @@ -6,12 +6,12 @@ import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode -data class MemberRef(val owner: String, val name: String, val desc: String) : Comparable { - constructor(clazz: ClassNode, field: FieldNode) : this(clazz.name, field.name, field.desc) - constructor(clazz: ClassNode, method: MethodNode) : this(clazz.name, method.name, method.desc) - constructor(fieldInsn: FieldInsnNode) : this(fieldInsn.owner, fieldInsn.name, fieldInsn.desc) - constructor(methodInsn: MethodInsnNode) : this(methodInsn.owner, methodInsn.name, methodInsn.desc) - constructor(owner: String, desc: MemberDesc) : this(owner, desc.name, desc.desc) +public data class MemberRef(val owner: String, val name: String, val desc: String) : Comparable { + public constructor(clazz: ClassNode, field: FieldNode) : this(clazz.name, field.name, field.desc) + public constructor(clazz: ClassNode, method: MethodNode) : this(clazz.name, method.name, method.desc) + public constructor(fieldInsn: FieldInsnNode) : this(fieldInsn.owner, fieldInsn.name, fieldInsn.desc) + public constructor(methodInsn: MethodInsnNode) : this(methodInsn.owner, methodInsn.name, methodInsn.desc) + public constructor(owner: String, desc: MemberDesc) : this(owner, desc.name, desc.desc) override fun compareTo(other: MemberRef): Int { var result = owner.compareTo(other.owner) @@ -31,10 +31,10 @@ data class MemberRef(val owner: String, val name: String, val desc: String) : Co return "$owner.$name $desc" } - companion object { + public companion object { private val STRING_REGEX = Regex("([^.]+)[.]([^ ]+) (.+)") - fun fromString(str: String): MemberRef { + public fun fromString(str: String): MemberRef { val result = STRING_REGEX.matchEntire(str) require(result != null) return MemberRef(result.groupValues[1], result.groupValues[2], result.groupValues[3]) diff --git a/asm/src/main/java/dev/openrs2/asm/MemberRefDeserializer.kt b/asm/src/main/java/dev/openrs2/asm/MemberRefDeserializer.kt index cef2eb64e0..0d1e29d087 100644 --- a/asm/src/main/java/dev/openrs2/asm/MemberRefDeserializer.kt +++ b/asm/src/main/java/dev/openrs2/asm/MemberRefDeserializer.kt @@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.deser.std.StdDeserializer -object MemberRefDeserializer : StdDeserializer(MemberRef::class.java) { +public object MemberRefDeserializer : StdDeserializer(MemberRef::class.java) { override fun deserialize(parser: JsonParser, ctx: DeserializationContext): MemberRef { return MemberRef.fromString(ctx.readValue(parser, String::class.java)) } diff --git a/asm/src/main/java/dev/openrs2/asm/MemberRefKeyDeserializer.kt b/asm/src/main/java/dev/openrs2/asm/MemberRefKeyDeserializer.kt index 8561d27fa6..0f8a9f98c4 100644 --- a/asm/src/main/java/dev/openrs2/asm/MemberRefKeyDeserializer.kt +++ b/asm/src/main/java/dev/openrs2/asm/MemberRefKeyDeserializer.kt @@ -3,7 +3,7 @@ package dev.openrs2.asm import com.fasterxml.jackson.databind.DeserializationContext import com.fasterxml.jackson.databind.KeyDeserializer -object MemberRefKeyDeserializer : KeyDeserializer() { +public object MemberRefKeyDeserializer : KeyDeserializer() { override fun deserializeKey(key: String, ctx: DeserializationContext): Any { return MemberRef.fromString(key) } diff --git a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt index ef8c62c6e8..9c061b4da8 100644 --- a/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt +++ b/asm/src/main/java/dev/openrs2/asm/MethodNodeUtils.kt @@ -33,7 +33,7 @@ private fun remapAll(indexes: List, argType: Type, localIndex: Int, newLoca return indexes.mapTo(mutableListOf()) { remap(it, argType, localIndex, newLocalIndex) } } -fun MethodNode.removeArgument(argIndex: Int) { +public fun MethodNode.removeArgument(argIndex: Int) { // remove argument from the descriptor val type = Type.getType(desc) val argType = type.argumentTypes[argIndex] @@ -129,7 +129,7 @@ fun MethodNode.removeArgument(argIndex: Int) { } } -fun MethodNode.removeDeadCode(owner: String) { +public fun MethodNode.removeDeadCode(owner: String) { var changed: Boolean do { changed = false @@ -152,10 +152,10 @@ fun MethodNode.removeDeadCode(owner: String) { } while (changed) } -val MethodNode.hasCode +public val MethodNode.hasCode: Boolean get() = access and (Opcodes.ACC_NATIVE or Opcodes.ACC_ABSTRACT) == 0 -fun MethodNode.copy(): MethodNode { +public fun MethodNode.copy(): MethodNode { val copy = MethodNode( access, name, diff --git a/asm/src/main/java/dev/openrs2/asm/NopClassVisitor.kt b/asm/src/main/java/dev/openrs2/asm/NopClassVisitor.kt index 2e700ff5e7..d5f0a92791 100644 --- a/asm/src/main/java/dev/openrs2/asm/NopClassVisitor.kt +++ b/asm/src/main/java/dev/openrs2/asm/NopClassVisitor.kt @@ -3,4 +3,4 @@ package dev.openrs2.asm import org.objectweb.asm.ClassVisitor import org.objectweb.asm.Opcodes -object NopClassVisitor : ClassVisitor(Opcodes.ASM8) +public object NopClassVisitor : ClassVisitor(Opcodes.ASM8) diff --git a/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt b/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt index c3ef4e6be6..0c75c38904 100644 --- a/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/StackMetadata.kt @@ -9,7 +9,7 @@ import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MultiANewArrayInsnNode -data class StackMetadata(val pops: Int, val pushes: Int) +public data class StackMetadata(val pops: Int, val pushes: Int) private val NONE = StackMetadata(0, 0) private val POP1 = StackMetadata(1, 0) @@ -181,7 +181,7 @@ private val SIMPLE_OPCODES = mapOf( Opcodes.IFNONNULL to POP1 ) -val AbstractInsnNode.stackMetadata +public val AbstractInsnNode.stackMetadata: StackMetadata get() = when (this) { is LdcInsnNode -> if (cst is Double || cst is Long) { PUSH2 diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt index 8094df0714..bba9824874 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/AsmClassMetadata.kt @@ -4,7 +4,7 @@ import dev.openrs2.asm.MemberDesc import org.objectweb.asm.Opcodes import org.objectweb.asm.tree.ClassNode -class AsmClassMetadata( +public class AsmClassMetadata( private val classPath: ClassPath, private val clazz: ClassNode, override val dependency: Boolean @@ -12,19 +12,19 @@ class AsmClassMetadata( override val name: String get() = clazz.name - override val `interface` + override val `interface`: Boolean get() = clazz.access and Opcodes.ACC_INTERFACE != 0 - override val superClass + override val superClass: ClassMetadata? get() = clazz.superName?.let { classPath[it] ?: error("Failed to find $it on provided classpath.") } - override val superInterfaces + override val superInterfaces: List get() = clazz.interfaces.map { classPath[it] ?: error("Failed to find $it on provided classpath.") } - override val fields + override val fields: List get() = clazz.fields.map(::MemberDesc) - override val methods + override val methods: List get() = clazz.methods.map(::MemberDesc) override fun getFieldAccess(field: MemberDesc): Int? { diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt index 2c20b65d7e..ed7c444641 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ClassMetadata.kt @@ -2,16 +2,16 @@ package dev.openrs2.asm.classpath import dev.openrs2.asm.MemberDesc -abstract class ClassMetadata { - abstract val name: String - abstract val dependency: Boolean - abstract val `interface`: Boolean - abstract val superClass: ClassMetadata? - abstract val superInterfaces: List - abstract val fields: List - abstract val methods: List - - val superClassAndInterfaces: List +public abstract class ClassMetadata { + public abstract val name: String + public abstract val dependency: Boolean + public abstract val `interface`: Boolean + public abstract val superClass: ClassMetadata? + public abstract val superInterfaces: List + public abstract val fields: List + public abstract val methods: List + + public val superClassAndInterfaces: List get() { val clazz = superClass return if (clazz != null) { @@ -21,10 +21,10 @@ abstract class ClassMetadata { } } - abstract fun getFieldAccess(field: MemberDesc): Int? - abstract fun getMethodAccess(method: MemberDesc): Int? + public abstract fun getFieldAccess(field: MemberDesc): Int? + public abstract fun getMethodAccess(method: MemberDesc): Int? - fun isOverride(method: MemberDesc): Boolean { + public fun isOverride(method: MemberDesc): Boolean { val superClass = this.superClass if (superClass != null) { if (method in superClass.methods) { @@ -49,7 +49,7 @@ abstract class ClassMetadata { return false } - fun isAssignableFrom(type: ClassMetadata): Boolean { + public fun isAssignableFrom(type: ClassMetadata): Boolean { return type == this || isSuperClassOf(type) || isSuperInterfaceOf(type) } @@ -71,7 +71,7 @@ abstract class ClassMetadata { return false } - fun resolveField(member: MemberDesc): ClassMetadata? { + public fun resolveField(member: MemberDesc): ClassMetadata? { // see https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-5.html#jvms-5.4.3.2 if (fields.contains(member)) { diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt index 30ce329ca3..056e4a00b9 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ClassPath.kt @@ -10,10 +10,10 @@ import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.ClassNode import java.util.IdentityHashMap -class ClassPath( +public class ClassPath( private val runtime: ClassLoader, private val dependencies: List, - val libraries: List + public val libraries: List ) { private val cache = mutableMapOf() @@ -26,9 +26,9 @@ class ClassPath( * Transformers to avoid adding extraneous labels until the last possible * moment, which would confuse some of our analyses if added earlier. */ - val originalPcs = IdentityHashMap() + public val originalPcs: MutableMap = IdentityHashMap() - val libraryClasses: Sequence + public val libraryClasses: Sequence get() = libraries.asSequence().flatten().map { get(it.name)!! } private inline fun computeIfAbsent(name: String, f: (String) -> ClassMetadata?): ClassMetadata? { @@ -41,7 +41,7 @@ class ClassPath( return clazz } - operator fun get(name: String): ClassMetadata? = computeIfAbsent(name) { + public operator fun get(name: String): ClassMetadata? = computeIfAbsent(name) { for (library in libraries) { val clazz = library[name] if (clazz != null) { @@ -65,7 +65,7 @@ class ClassPath( return@computeIfAbsent ReflectionClassMetadata(this, clazz) } - fun getClassNode(name: String): ClassNode? { + public fun getClassNode(name: String): ClassNode? { for (library in libraries) { val clazz = library[name] if (clazz != null) { @@ -76,7 +76,7 @@ class ClassPath( return null } - fun remap(remapper: ExtendedRemapper) { + public fun remap(remapper: ExtendedRemapper) { for (library in libraries) { library.remap(remapper) } @@ -84,11 +84,11 @@ class ClassPath( cache.clear() } - fun createInheritedFieldSets(): DisjointSet { + public fun createInheritedFieldSets(): DisjointSet { return createInheritedMemberSets(ClassMetadata::fields, ClassMetadata::getFieldAccess, fields = true) } - fun createInheritedMethodSets(): DisjointSet { + public fun createInheritedMethodSets(): DisjointSet { return createInheritedMemberSets(ClassMetadata::methods, ClassMetadata::getMethodAccess, fields = false) } diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ExtendedRemapper.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ExtendedRemapper.kt index 3cfbc2db8f..c324465ff5 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ExtendedRemapper.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ExtendedRemapper.kt @@ -3,20 +3,20 @@ package dev.openrs2.asm.classpath import org.objectweb.asm.commons.Remapper import org.objectweb.asm.tree.AbstractInsnNode -abstract class ExtendedRemapper : Remapper() { - open fun getFieldInitializer(owner: String, name: String, descriptor: String): List? { +public abstract class ExtendedRemapper : Remapper() { + public open fun getFieldInitializer(owner: String, name: String, descriptor: String): List? { return null } - open fun mapFieldOwner(owner: String, name: String, descriptor: String): String { + public open fun mapFieldOwner(owner: String, name: String, descriptor: String): String { return mapType(owner) } - open fun mapMethodOwner(owner: String, name: String, descriptor: String): String { + public open fun mapMethodOwner(owner: String, name: String, descriptor: String): String { return mapType(owner) } - open fun mapArgumentName( + public open fun mapArgumentName( owner: String, name: String, descriptor: String, diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt b/asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt index 21faff4ee5..fcc7668d35 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/JsrInliner.kt @@ -5,7 +5,7 @@ import org.objectweb.asm.MethodVisitor import org.objectweb.asm.Opcodes import org.objectweb.asm.commons.JSRInlinerAdapter -class JsrInliner(cv: ClassVisitor) : ClassVisitor(Opcodes.ASM8, cv) { +public class JsrInliner(cv: ClassVisitor) : ClassVisitor(Opcodes.ASM8, cv) { override fun visitMethod( access: Int, name: String, 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 696bc96726..1cc40524f4 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/Library.kt @@ -10,10 +10,10 @@ import java.nio.file.Path import java.util.SortedMap import java.util.TreeMap -class Library(val name: String) : Iterable { +public class Library(public val name: String) : Iterable { private var classes: SortedMap = TreeMap() - constructor(name: String, library: Library) : this(name) { + public constructor(name: String, library: Library) : this(name) { for (clazz in library.classes.values) { val copy = ClassNode() clazz.accept(copy) @@ -21,19 +21,19 @@ class Library(val name: String) : Iterable { } } - operator fun contains(name: String): Boolean { + public operator fun contains(name: String): Boolean { return classes.containsKey(name) } - operator fun get(name: String): ClassNode? { + public operator fun get(name: String): ClassNode? { return classes[name] } - fun add(clazz: ClassNode): ClassNode? { + public fun add(clazz: ClassNode): ClassNode? { return classes.put(clazz.name, clazz) } - fun remove(name: String): ClassNode? { + public fun remove(name: String): ClassNode? { return classes.remove(name) } @@ -41,11 +41,11 @@ class Library(val name: String) : Iterable { return classes.values.iterator() } - fun remap(remapper: ExtendedRemapper) { + public fun remap(remapper: ExtendedRemapper) { classes = LibraryRemapper(remapper, classes).remap() } - fun write(path: Path, writer: LibraryWriter, classPath: ClassPath) { + public fun write(path: Path, writer: LibraryWriter, classPath: ClassPath) { logger.info { "Writing library $path" } path.useAtomicOutputStream { output -> @@ -53,10 +53,10 @@ class Library(val name: String) : Iterable { } } - companion object { + public companion object { private val logger = InlineLogger() - fun read(name: String, path: Path, reader: LibraryReader): Library { + public fun read(name: String, path: Path, reader: LibraryReader): Library { logger.info { "Reading library $path" } val classes = Files.newInputStream(path).use { input -> diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/LibraryRemapper.kt b/asm/src/main/java/dev/openrs2/asm/classpath/LibraryRemapper.kt index 504371c437..4f3d2ef0d3 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/LibraryRemapper.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/LibraryRemapper.kt @@ -15,7 +15,7 @@ import java.util.SortedMap import java.util.TreeMap import kotlin.math.max -class LibraryRemapper( +public class LibraryRemapper( private val remapper: ExtendedRemapper, private var classes: SortedMap ) { @@ -34,7 +34,7 @@ class LibraryRemapper( private val splicedFields = mutableSetOf() private val methods = mutableListOf() - fun remap(): SortedMap { + public fun remap(): SortedMap { // extract static fields/methods that are being moved between classes extractFields() extractMethods() diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt b/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt index cbc8352833..f7e6490179 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/ReflectionClassMetadata.kt @@ -7,7 +7,7 @@ import org.objectweb.asm.Type private val Class<*>.asmName: String get() = name.toInternalClassName() -class ReflectionClassMetadata(private val classPath: ClassPath, private val clazz: Class<*>) : ClassMetadata() { +public class ReflectionClassMetadata(private val classPath: ClassPath, private val clazz: Class<*>) : ClassMetadata() { override val name: String get() = clazz.asmName @@ -20,13 +20,13 @@ class ReflectionClassMetadata(private val classPath: ClassPath, private val claz override val superClass: ClassMetadata? get() = if (clazz.superclass != null) classPath[clazz.superclass.asmName]!! else null - override val superInterfaces + override val superInterfaces: List get() = clazz.interfaces.map { classPath[it.asmName]!! } - override val fields + override val fields: List get() = clazz.declaredFields.map { MemberDesc(it.name, Type.getDescriptor(it.type)) } - override val methods + override val methods: List get() = clazz.declaredMethods.map { MemberDesc(it.name, Type.getMethodDescriptor(it)) } override fun getFieldAccess(field: MemberDesc): Int? { diff --git a/asm/src/main/java/dev/openrs2/asm/classpath/StackFrameClassWriter.kt b/asm/src/main/java/dev/openrs2/asm/classpath/StackFrameClassWriter.kt index 2f6ce2dc1f..9bb26a3600 100644 --- a/asm/src/main/java/dev/openrs2/asm/classpath/StackFrameClassWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/classpath/StackFrameClassWriter.kt @@ -2,7 +2,7 @@ package dev.openrs2.asm.classpath import org.objectweb.asm.ClassWriter -class StackFrameClassWriter(private val classPath: ClassPath) : ClassWriter(COMPUTE_FRAMES) { +public class StackFrameClassWriter(private val classPath: ClassPath) : ClassWriter(COMPUTE_FRAMES) { override fun getCommonSuperClass(type1: String, type2: String): String { var c = classPath[type1]!! val d = classPath[type2]!! diff --git a/asm/src/main/java/dev/openrs2/asm/filter/AnyClassFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/AnyClassFilter.kt index 9b1a718ce5..1d8c522fcf 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/AnyClassFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/AnyClassFilter.kt @@ -1,6 +1,6 @@ package dev.openrs2.asm.filter -object AnyClassFilter : ClassFilter { +public object AnyClassFilter : ClassFilter { override fun matches(name: String): Boolean { return true } diff --git a/asm/src/main/java/dev/openrs2/asm/filter/AnyMemberFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/AnyMemberFilter.kt index b7aa2f8016..a7636c3f47 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/AnyMemberFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/AnyMemberFilter.kt @@ -1,6 +1,6 @@ package dev.openrs2.asm.filter -object AnyMemberFilter : MemberFilter { +public object AnyMemberFilter : MemberFilter { override fun matches(owner: String, name: String, desc: String): Boolean { return true } diff --git a/asm/src/main/java/dev/openrs2/asm/filter/ClassFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/ClassFilter.kt index d260860091..dfd8835192 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/ClassFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/ClassFilter.kt @@ -1,5 +1,5 @@ package dev.openrs2.asm.filter -interface ClassFilter { - fun matches(name: String): Boolean +public interface ClassFilter { + public fun matches(name: String): Boolean } diff --git a/asm/src/main/java/dev/openrs2/asm/filter/Glob.kt b/asm/src/main/java/dev/openrs2/asm/filter/Glob.kt index 3d5f9fc4ce..3e90ccfe58 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/Glob.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/Glob.kt @@ -1,11 +1,11 @@ package dev.openrs2.asm.filter -object Glob { - fun compile(pattern: String): Regex { +public object Glob { + public fun compile(pattern: String): Regex { return compile(pattern, className = false) } - fun compileClass(pattern: String): Regex { + public fun compileClass(pattern: String): Regex { return compile(pattern, className = true) } diff --git a/asm/src/main/java/dev/openrs2/asm/filter/GlobClassFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/GlobClassFilter.kt index 8a4514e246..97499ce8f7 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/GlobClassFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/GlobClassFilter.kt @@ -2,7 +2,7 @@ package dev.openrs2.asm.filter import com.fasterxml.jackson.annotation.JsonIgnore -class GlobClassFilter(@Suppress("CanBeParameter") private val patterns: List) : ClassFilter { +public class GlobClassFilter(@Suppress("CanBeParameter") private val patterns: List) : ClassFilter { @JsonIgnore private val compiledPatterns = patterns.map(Glob::compileClass).toList() diff --git a/asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt index 6827f15535..6a62d821ee 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt @@ -3,7 +3,7 @@ package dev.openrs2.asm.filter import com.fasterxml.jackson.annotation.JsonIgnore import dev.openrs2.asm.MemberRef -class GlobMemberFilter(@Suppress("CanBeParameter") private val patterns: List) : MemberFilter { +public class GlobMemberFilter(@Suppress("CanBeParameter") private val patterns: List) : MemberFilter { private data class CompiledPattern(val owner: Regex, val name: Regex, val desc: Regex) @JsonIgnore diff --git a/asm/src/main/java/dev/openrs2/asm/filter/MemberFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/MemberFilter.kt index 394a6c11c4..aa3059a864 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/MemberFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/MemberFilter.kt @@ -2,10 +2,10 @@ package dev.openrs2.asm.filter import dev.openrs2.asm.MemberRef -interface MemberFilter { - fun matches(owner: String, name: String, desc: String): Boolean +public interface MemberFilter { + public fun matches(owner: String, name: String, desc: String): Boolean - fun matches(member: MemberRef): Boolean { + public fun matches(member: MemberRef): Boolean { return matches(member.owner, member.name, member.desc) } } diff --git a/asm/src/main/java/dev/openrs2/asm/filter/UnionClassFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/UnionClassFilter.kt index 17b8cd39a8..48432dd163 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/UnionClassFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/UnionClassFilter.kt @@ -1,6 +1,6 @@ package dev.openrs2.asm.filter -class UnionClassFilter(vararg filters: ClassFilter) : ClassFilter { +public class UnionClassFilter(vararg filters: ClassFilter) : ClassFilter { private val filters = filters.toList() override fun matches(name: String): Boolean { diff --git a/asm/src/main/java/dev/openrs2/asm/filter/UnionMemberFilter.kt b/asm/src/main/java/dev/openrs2/asm/filter/UnionMemberFilter.kt index 2194fa93ad..84e1a228f2 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/UnionMemberFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/UnionMemberFilter.kt @@ -1,6 +1,6 @@ package dev.openrs2.asm.filter -class UnionMemberFilter(vararg filters: MemberFilter) : MemberFilter { +public class UnionMemberFilter(vararg filters: MemberFilter) : MemberFilter { private val filters = filters.toList() override fun matches(owner: String, name: String, desc: String): Boolean { diff --git a/asm/src/main/java/dev/openrs2/asm/io/AbstractJarLibraryWriter.kt b/asm/src/main/java/dev/openrs2/asm/io/AbstractJarLibraryWriter.kt index b07053dc3f..51295a498c 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/AbstractJarLibraryWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/AbstractJarLibraryWriter.kt @@ -12,7 +12,7 @@ import java.io.OutputStream import java.util.jar.JarEntry import java.util.jar.JarOutputStream -abstract class AbstractJarLibraryWriter : LibraryWriter { +public abstract class AbstractJarLibraryWriter : LibraryWriter { override fun write(output: OutputStream, classPath: ClassPath, classes: Iterable) { createJarOutputStream(output).use { jar -> for (clazz in classes) { diff --git a/asm/src/main/java/dev/openrs2/asm/io/JarLibraryReader.kt b/asm/src/main/java/dev/openrs2/asm/io/JarLibraryReader.kt index e19c58dada..046c4d2007 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/JarLibraryReader.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/JarLibraryReader.kt @@ -7,7 +7,7 @@ import org.objectweb.asm.tree.ClassNode import java.io.InputStream import java.util.jar.JarInputStream -object JarLibraryReader : LibraryReader { +public object JarLibraryReader : LibraryReader { private const val CLASS_SUFFIX = ".class" override fun read(input: InputStream): Iterable { diff --git a/asm/src/main/java/dev/openrs2/asm/io/JarLibraryWriter.kt b/asm/src/main/java/dev/openrs2/asm/io/JarLibraryWriter.kt index e2c5a34867..dc145bf2c0 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/JarLibraryWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/JarLibraryWriter.kt @@ -4,7 +4,7 @@ import dev.openrs2.util.io.DeterministicJarOutputStream import java.io.OutputStream import java.util.jar.JarOutputStream -object JarLibraryWriter : AbstractJarLibraryWriter() { +public object JarLibraryWriter : AbstractJarLibraryWriter() { override fun createJarOutputStream(output: OutputStream): JarOutputStream { return DeterministicJarOutputStream(output) } diff --git a/asm/src/main/java/dev/openrs2/asm/io/LibraryReader.kt b/asm/src/main/java/dev/openrs2/asm/io/LibraryReader.kt index 37802ea3db..9f7a2a4d8e 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/LibraryReader.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/LibraryReader.kt @@ -3,6 +3,6 @@ package dev.openrs2.asm.io import org.objectweb.asm.tree.ClassNode import java.io.InputStream -interface LibraryReader { - fun read(input: InputStream): Iterable +public interface LibraryReader { + public fun read(input: InputStream): Iterable } diff --git a/asm/src/main/java/dev/openrs2/asm/io/LibraryWriter.kt b/asm/src/main/java/dev/openrs2/asm/io/LibraryWriter.kt index 89dbd1ea10..4ca8befbdf 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/LibraryWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/LibraryWriter.kt @@ -4,6 +4,6 @@ import dev.openrs2.asm.classpath.ClassPath import org.objectweb.asm.tree.ClassNode import java.io.OutputStream -interface LibraryWriter { - fun write(output: OutputStream, classPath: ClassPath, classes: Iterable) +public interface LibraryWriter { + public fun write(output: OutputStream, classPath: ClassPath, classes: Iterable) } diff --git a/asm/src/main/java/dev/openrs2/asm/io/ManifestJarLibraryWriter.kt b/asm/src/main/java/dev/openrs2/asm/io/ManifestJarLibraryWriter.kt index 1fb04ecf69..72ef563a82 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/ManifestJarLibraryWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/ManifestJarLibraryWriter.kt @@ -5,7 +5,7 @@ import java.io.OutputStream import java.util.jar.JarOutputStream import java.util.jar.Manifest -class ManifestJarLibraryWriter(private val manifest: Manifest) : AbstractJarLibraryWriter() { +public class ManifestJarLibraryWriter(private val manifest: Manifest) : AbstractJarLibraryWriter() { override fun createJarOutputStream(output: OutputStream): JarOutputStream { return DeterministicJarOutputStream(output, manifest) } diff --git a/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryReader.kt b/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryReader.kt index 7ccb12fde0..724fe5189b 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryReader.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryReader.kt @@ -8,7 +8,7 @@ import java.io.InputStream import java.util.jar.JarOutputStream import java.util.jar.Pack200 -object Pack200LibraryReader : LibraryReader { +public object Pack200LibraryReader : LibraryReader { override fun read(input: InputStream): Iterable { ByteArrayOutputStream().use { tempOutput -> Gzip.createHeaderlessInputStream(input).use { gzipInput -> diff --git a/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryWriter.kt b/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryWriter.kt index deb4da9cc2..ba30e0ff4b 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/Pack200LibraryWriter.kt @@ -9,7 +9,7 @@ import java.io.OutputStream import java.util.jar.JarInputStream import java.util.jar.Pack200 -object Pack200LibraryWriter : LibraryWriter { +public object Pack200LibraryWriter : LibraryWriter { override fun write(output: OutputStream, classPath: ClassPath, classes: Iterable) { ByteArrayOutputStream().use { tempOutput -> JarLibraryWriter.write(tempOutput, classPath, classes) diff --git a/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryReader.kt b/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryReader.kt index 0e8b70b69a..d9759ed399 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryReader.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryReader.kt @@ -3,7 +3,7 @@ package dev.openrs2.asm.io import org.objectweb.asm.tree.ClassNode import java.io.InputStream -object PackClassLibraryReader : LibraryReader { +public object PackClassLibraryReader : LibraryReader { override fun read(input: InputStream): Iterable { // TODO(gpe): implement return emptyList() diff --git a/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryWriter.kt b/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryWriter.kt index 625c0cc012..0b0b10a029 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/PackClassLibraryWriter.kt @@ -4,7 +4,7 @@ import dev.openrs2.asm.classpath.ClassPath import org.objectweb.asm.tree.ClassNode import java.io.OutputStream -object PackClassLibraryWriter : LibraryWriter { +public object PackClassLibraryWriter : LibraryWriter { override fun write(output: OutputStream, classPath: ClassPath, classes: Iterable) { // TODO(gpe): implement } diff --git a/asm/src/main/java/dev/openrs2/asm/io/SignedJarLibraryWriter.kt b/asm/src/main/java/dev/openrs2/asm/io/SignedJarLibraryWriter.kt index 5f946cf73a..0779f11cd2 100644 --- a/asm/src/main/java/dev/openrs2/asm/io/SignedJarLibraryWriter.kt +++ b/asm/src/main/java/dev/openrs2/asm/io/SignedJarLibraryWriter.kt @@ -14,7 +14,7 @@ import java.nio.file.Files import java.util.jar.JarInputStream import java.util.jar.Manifest -class SignedJarLibraryWriter( +public class SignedJarLibraryWriter( private val manifest: Manifest, private val keyStore: Pkcs12KeyStore ) : LibraryWriter { 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 8c96709e5c..57862f2148 100644 --- a/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt +++ b/asm/src/main/java/dev/openrs2/asm/transform/Transformer.kt @@ -7,8 +7,8 @@ import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.FieldNode import org.objectweb.asm.tree.MethodNode -abstract class Transformer { - open fun transform(classPath: ClassPath) { +public abstract class Transformer { + public open fun transform(classPath: ClassPath) { preTransform(classPath) var changed: Boolean diff --git a/buffer/src/main/java/dev/openrs2/buffer/ReferenceCountedExtensions.kt b/buffer/src/main/java/dev/openrs2/buffer/ReferenceCountedExtensions.kt index e8e8a1ab13..656998e9a2 100644 --- a/buffer/src/main/java/dev/openrs2/buffer/ReferenceCountedExtensions.kt +++ b/buffer/src/main/java/dev/openrs2/buffer/ReferenceCountedExtensions.kt @@ -2,7 +2,7 @@ package dev.openrs2.buffer import io.netty.util.ReferenceCounted -inline fun T.use(block: (T) -> R): R { +public inline fun T.use(block: (T) -> R): R { try { return block(this) } finally { diff --git a/build.gradle.kts b/build.gradle.kts index 039d1cae10..0c52e62727 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -55,6 +55,12 @@ allprojects { } } + plugins.withType { + kotlin { + explicitApi() + } + } + plugins.withType { configure { // see https://github.com/pinterest/ktlint/issues/764 diff --git a/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt b/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt index 2a85d945a4..78725ef0d8 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt @@ -4,9 +4,9 @@ import com.github.ajalt.clikt.core.CliktCommand import com.google.inject.Guice import java.nio.file.Paths -fun main(args: Array) = BundleCommand().main(args) +public fun main(args: Array): Unit = BundleCommand().main(args) -class BundleCommand : CliktCommand(name = "bundle") { +public class BundleCommand : CliktCommand(name = "bundle") { override fun run() { val injector = Guice.createInjector(BundlerModule) val bundler = injector.getInstance(Bundler::class.java) diff --git a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt index dd170dc443..46ae1f6c33 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/Bundler.kt @@ -23,7 +23,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class Bundler @Inject constructor( +public class Bundler @Inject constructor( @BundlerQualifier private val transformers: Set<@JvmSuppressWildcards Transformer>, private val config: Config ) { @@ -39,7 +39,7 @@ class Bundler @Inject constructor( mainAttributes[PERMISSIONS] = "all-permissions" } - fun run(input: Path, output: Path, keyStorePath: Path) { + public fun run(input: Path, output: Path, keyStorePath: Path) { // read input jars/packs logger.info { "Reading input jars" } val unpacker = Library.read("unpackclass", input.resolve("unpackclass.pack"), JarLibraryReader) diff --git a/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt b/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt index 299975cc52..0e0269e1d0 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt @@ -18,7 +18,7 @@ import dev.openrs2.bundler.transform.TypoTransformer import dev.openrs2.conf.ConfigModule import dev.openrs2.crypto.CryptoModule -object BundlerModule : AbstractModule() { +public object BundlerModule : AbstractModule() { override fun configure() { install(ConfigModule) install(CryptoModule) diff --git a/bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt b/bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt index 21baf80da2..2f6d02fdb7 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/BundlerQualifier.kt @@ -5,4 +5,4 @@ import javax.inject.Qualifier @Qualifier @Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) -annotation class BundlerQualifier +public annotation class BundlerQualifier diff --git a/bundler/src/main/java/dev/openrs2/bundler/Resource.kt b/bundler/src/main/java/dev/openrs2/bundler/Resource.kt index f469255eb6..530904cace 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/Resource.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/Resource.kt @@ -11,31 +11,31 @@ import java.security.MessageDigest import java.util.zip.CRC32 import java.util.zip.Deflater -class Resource( - val source: String, - val destination: String, - val crc: Int, - val digest: ByteArray, - val uncompressedSize: Int, - val content: ByteArray +public class Resource( + public val source: String, + public val destination: String, + public val crc: Int, + public val digest: ByteArray, + public val uncompressedSize: Int, + public val content: ByteArray ) { - val sourceWithCrc: String + public val sourceWithCrc: String get() = source.replace(".", "_$crc.") - val compressedSize: Int + public val compressedSize: Int get() = content.size init { require(digest.size == 20) } - fun write(dir: Path) { + public fun write(dir: Path) { val path = dir.resolve(source) logger.info { "Writing resource $path" } Files.write(path, content) } - companion object { + public companion object { private val logger = InlineLogger() private fun compress(source: String, destination: String, uncompressed: ByteArray): Resource { @@ -66,7 +66,7 @@ class Resource( return Resource(source, destination, crc.value.toInt(), digest.digest(), uncompressed.size, content) } - fun compressLibrary( + public fun compressLibrary( source: String, destination: String, classPath: ClassPath, @@ -85,7 +85,7 @@ class Resource( return compress(source, destination, uncompressed) } - fun compressGlNatives() = listOf( + public fun compressGlNatives(): List> = listOf( // Windows i386 listOf( compressNative("jaggl_0_0.lib", "jaggl.dll", "windows-i386/jaggl.dll") @@ -119,7 +119,7 @@ class Resource( ) ) - fun compressMiscNatives() = listOf( + public fun compressMiscNatives(): List = listOf( compressNative("jagmisc_0.lib", "jagmisc.dll", "windows-i386/jagmisc.dll"), compressNative("jagmisc_1.lib", "jagmisc.dll", "windows-amd64/jagmisc.dll") ) diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt index 2c5e6461f5..80d091dd0c 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt @@ -15,7 +15,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class BufferSizeTransformer : Transformer() { +public class BufferSizeTransformer : Transformer() { private var buffer: MemberRef? = null private var buffersResized = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt index 59a4cda9fe..673cbc9999 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt @@ -12,7 +12,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class CachePathTransformer @Inject constructor( +public class CachePathTransformer @Inject constructor( private val config: Config ) : Transformer() { private var paths = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/DomainTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/DomainTransformer.kt index 091fcd8f9a..be31cc843f 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/DomainTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/DomainTransformer.kt @@ -12,7 +12,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class DomainTransformer @Inject constructor( +public class DomainTransformer @Inject constructor( private val config: Config ) : Transformer() { private var domains = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt index b30f188d09..ead3a60a9a 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt @@ -14,7 +14,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class HostCheckTransformer : Transformer() { +public class HostCheckTransformer : Transformer() { private var hostChecks = 0 override fun preTransform(classPath: ClassPath) { diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt index 680e152958..e3e7d3068b 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt @@ -13,7 +13,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class LoadLibraryTransformer : Transformer() { +public class LoadLibraryTransformer : Transformer() { private var jnilibs = 0 private var amd64Checks = 0 private var sunOsChecks = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt index ef8127eef4..963d32f797 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt @@ -15,7 +15,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class MacResizeTransformer : Transformer() { +public class MacResizeTransformer : Transformer() { private var branchesRemoved = 0 override fun preTransform(classPath: ClassPath) { diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/MemoryAllocationTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/MemoryAllocationTransformer.kt index 76a6ba7a49..c3f99c0147 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/MemoryAllocationTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/MemoryAllocationTransformer.kt @@ -15,7 +15,7 @@ import org.objectweb.asm.tree.VarInsnNode import javax.inject.Singleton @Singleton -class MemoryAllocationTransformer : Transformer() { +public class MemoryAllocationTransformer : Transformer() { private var usedMemoryExprsZeroed = 0 override fun preTransform(classPath: ClassPath) { diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/NameTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/NameTransformer.kt index 133d724442..2617318d5f 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/NameTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/NameTransformer.kt @@ -12,7 +12,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class NameTransformer @Inject constructor( +public class NameTransformer @Inject constructor( private val config: Config ) : Transformer() { private var names = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt index e987302004..21a56fa0f1 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt @@ -22,7 +22,7 @@ import org.objectweb.asm.tree.VarInsnNode import javax.inject.Singleton @Singleton -class PlatformDetectionTransformer : Transformer() { +public class PlatformDetectionTransformer : Transformer() { private var glBlocks = 0 private var miscBlocks = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/PublicKeyTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/PublicKeyTransformer.kt index 3de9983ebd..a8906e47a8 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/PublicKeyTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/PublicKeyTransformer.kt @@ -12,7 +12,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class PublicKeyTransformer @Inject constructor(private val key: RSAPrivateCrtKeyParameters) : Transformer() { +public class PublicKeyTransformer @Inject constructor(private val key: RSAPrivateCrtKeyParameters) : Transformer() { private var exponents = 0 private var moduli = 0 diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt index 933ffeb4f7..1cdc2e57c2 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt @@ -17,7 +17,7 @@ import org.objectweb.asm.tree.MethodInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.TypeInsnNode -class ResourceTransformer( +public class ResourceTransformer( private val resources: List? = null, private val glResources: List> = Resource.compressGlNatives(), private val miscResources: List = Resource.compressMiscNatives() diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt index 24c19fe144..3c81c85e61 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt @@ -14,7 +14,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class RightClickTransformer : Transformer() { +public class RightClickTransformer : Transformer() { private var metaDownCalls = 0 override fun preTransform(classPath: ClassPath) { diff --git a/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt b/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt index 13a2e997c3..6a2004cea4 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt @@ -10,7 +10,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class TypoTransformer : Transformer() { +public class TypoTransformer : Transformer() { private var errorsFixed = 0 override fun preTransform(classPath: ClassPath) { diff --git a/cache/src/main/java/dev/openrs2/cache/BufferedFileChannel.kt b/cache/src/main/java/dev/openrs2/cache/BufferedFileChannel.kt index 2c41b64bac..80a26f2c52 100644 --- a/cache/src/main/java/dev/openrs2/cache/BufferedFileChannel.kt +++ b/cache/src/main/java/dev/openrs2/cache/BufferedFileChannel.kt @@ -9,7 +9,7 @@ import java.nio.channels.FileChannel import kotlin.math.max import kotlin.math.min -class BufferedFileChannel( +public class BufferedFileChannel( private val channel: FileChannel, readBufferSize: Int, writeBufferSize: Int, @@ -23,7 +23,7 @@ class BufferedFileChannel( private val writeBuffer = alloc.buffer(writeBufferSize, writeBufferSize) private var writePos = -1L - fun read(pos: Long, dest: ByteBuf, len: Int) { + public fun read(pos: Long, dest: ByteBuf, len: Int) { require(pos >= 0) require(len <= dest.writableBytes()) @@ -165,7 +165,7 @@ class BufferedFileChannel( } } - fun write(pos: Long, src: ByteBuf, len: Int) { + public fun write(pos: Long, src: ByteBuf, len: Int) { require(pos >= 0) require(len <= src.readableBytes()) @@ -277,7 +277,7 @@ class BufferedFileChannel( } } - fun size(): Long { + public fun size(): Long { return size } diff --git a/cache/src/main/java/dev/openrs2/cache/DiskStore.kt b/cache/src/main/java/dev/openrs2/cache/DiskStore.kt index df72191695..c2164932b6 100644 --- a/cache/src/main/java/dev/openrs2/cache/DiskStore.kt +++ b/cache/src/main/java/dev/openrs2/cache/DiskStore.kt @@ -17,7 +17,7 @@ import kotlin.math.min * A [Store] implementation compatible with the native `main_file_cache.dat2` * and `main_file_cache.idx*` format used by the client. */ -class DiskStore private constructor( +public class DiskStore private constructor( private val root: Path, private val data: BufferedFileChannel, private val indexes: Array, @@ -436,7 +436,7 @@ class DiskStore private constructor( } } - companion object { + public companion object { private const val INDEX_ENTRY_SIZE = 6 private const val BLOCK_HEADER_SIZE = 8 @@ -460,7 +460,7 @@ class DiskStore private constructor( return root.resolve("main_file_cache.idx$archive") } - fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { + public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { val data = BufferedFileChannel( FileChannel.open(dataPath(root), READ, WRITE), DATA_BUFFER_SIZE, @@ -485,7 +485,7 @@ class DiskStore private constructor( return DiskStore(root, data, archives, alloc) } - fun create(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { + public fun create(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { Files.createDirectories(root) val data = BufferedFileChannel( diff --git a/cache/src/main/java/dev/openrs2/cache/FlatFileStore.kt b/cache/src/main/java/dev/openrs2/cache/FlatFileStore.kt index 3de351baae..0b7c81cc48 100644 --- a/cache/src/main/java/dev/openrs2/cache/FlatFileStore.kt +++ b/cache/src/main/java/dev/openrs2/cache/FlatFileStore.kt @@ -15,7 +15,7 @@ import java.nio.file.Path * content-addressable version control systems, such as Git, than the native * format used by the client. */ -class FlatFileStore private constructor( +public class FlatFileStore private constructor( private val root: Path, private val alloc: ByteBufAllocator ) : Store { @@ -108,12 +108,12 @@ class FlatFileStore private constructor( // no-op } - companion object { + public companion object { private val ARCHIVE_NAME = Regex("[1-9][0-9]*") private val GROUP_NAME = Regex("[1-9][0-9]*[.]dat") private const val GROUP_EXTENSION = ".dat" - fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { + public fun open(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { if (!Files.isDirectory(root)) { throw FileNotFoundException() } @@ -121,7 +121,7 @@ class FlatFileStore private constructor( return FlatFileStore(root, alloc) } - fun create(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { + public fun create(root: Path, alloc: ByteBufAllocator = ByteBufAllocator.DEFAULT): Store { Files.createDirectories(root) return FlatFileStore(root, alloc) } diff --git a/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt b/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt index 2dd11193de..8cc8fa4f08 100644 --- a/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt +++ b/cache/src/main/java/dev/openrs2/cache/Js5Compression.kt @@ -8,8 +8,8 @@ import io.netty.buffer.ByteBuf import io.netty.buffer.ByteBufInputStream import io.netty.buffer.ByteBufOutputStream -object Js5Compression { - fun compress(input: ByteBuf, type: Js5CompressionType, key: XteaKey = XteaKey.ZERO): ByteBuf { +public object Js5Compression { + public fun compress(input: ByteBuf, type: Js5CompressionType, key: XteaKey = XteaKey.ZERO): ByteBuf { input.alloc().buffer().use { output -> output.writeByte(type.ordinal) @@ -48,7 +48,7 @@ object Js5Compression { } } - fun compressBest(input: ByteBuf, enableLzma: Boolean = false, key: XteaKey = XteaKey.ZERO): ByteBuf { + public fun compressBest(input: ByteBuf, enableLzma: Boolean = false, key: XteaKey = XteaKey.ZERO): ByteBuf { var best = compress(input.slice(), Js5CompressionType.NONE, key) try { for (type in Js5CompressionType.values()) { @@ -73,7 +73,7 @@ object Js5Compression { } } - fun uncompress(input: ByteBuf, key: XteaKey = XteaKey.ZERO): ByteBuf { + public fun uncompress(input: ByteBuf, key: XteaKey = XteaKey.ZERO): ByteBuf { val typeId = input.readUnsignedByte().toInt() val type = Js5CompressionType.fromOrdinal(typeId) require(type != null) { diff --git a/cache/src/main/java/dev/openrs2/cache/Js5CompressionType.kt b/cache/src/main/java/dev/openrs2/cache/Js5CompressionType.kt index 83706b56d2..9f784519d1 100644 --- a/cache/src/main/java/dev/openrs2/cache/Js5CompressionType.kt +++ b/cache/src/main/java/dev/openrs2/cache/Js5CompressionType.kt @@ -8,13 +8,13 @@ import java.io.OutputStream import java.util.zip.Deflater import java.util.zip.GZIPInputStream -enum class Js5CompressionType { +public enum class Js5CompressionType { NONE, BZIP2, GZIP, LZMA; - fun createInputStream(input: InputStream, length: Int): InputStream { + public fun createInputStream(input: InputStream, length: Int): InputStream { return when (this) { NONE -> input BZIP2 -> Bzip2.createHeaderlessInputStream(input) @@ -23,7 +23,7 @@ enum class Js5CompressionType { } } - fun createOutputStream(output: OutputStream): OutputStream { + public fun createOutputStream(output: OutputStream): OutputStream { return when (this) { NONE -> output BZIP2 -> Bzip2.createHeaderlessOutputStream(output) @@ -39,8 +39,8 @@ enum class Js5CompressionType { } } - companion object { - fun fromOrdinal(ordinal: Int): Js5CompressionType? { + public companion object { + public fun fromOrdinal(ordinal: Int): Js5CompressionType? { val values = values() return if (ordinal >= 0 && ordinal < values.size) { values[ordinal] diff --git a/cache/src/main/java/dev/openrs2/cache/Store.kt b/cache/src/main/java/dev/openrs2/cache/Store.kt index 23eb048aaa..3063d4aabd 100644 --- a/cache/src/main/java/dev/openrs2/cache/Store.kt +++ b/cache/src/main/java/dev/openrs2/cache/Store.kt @@ -10,7 +10,7 @@ import java.io.IOException * A low-level interface for reading and writing raw groups directly to and * from a collection of JS5 archives. */ -interface Store : Flushable, Closeable { +public interface Store : Flushable, Closeable { /** * Checks whether an archive exists. * @param archive the archive ID. @@ -18,7 +18,7 @@ interface Store : Flushable, Closeable { * @throws IllegalArgumentException if the archive ID is out of bounds. * @throws IOException if an underlying I/O error occurs. */ - fun exists(archive: Int): Boolean + public fun exists(archive: Int): Boolean /** * Checks whether a group exists. @@ -29,14 +29,14 @@ interface Store : Flushable, Closeable { * bounds. * @throws IOException if an underlying I/O error occurs. */ - fun exists(archive: Int, group: Int): Boolean + public fun exists(archive: Int, group: Int): Boolean /** * Lists all archives in the store. * @return a sorted list of archive IDs. * @throws IOException if an underlying I/O error occurs. */ - fun list(): List + public fun list(): List /** * Lists all groups in an archive. @@ -47,7 +47,7 @@ interface Store : Flushable, Closeable { * @throws FileNotFoundException if the archive does not exist. * @throws IOException if an underlying I/O error occurs. */ - fun list(archive: Int): List + public fun list(archive: Int): List /** * Creates an archive. Does nothing if the archive already exists. @@ -55,7 +55,7 @@ interface Store : Flushable, Closeable { * @throws IllegalArgumentException if the archive ID is out of bounds. * @throws IOException if an underlying I/O error occurs. */ - fun create(archive: Int) + public fun create(archive: Int) /** * Reads a group. @@ -71,7 +71,7 @@ interface Store : Flushable, Closeable { * @throws StoreCorruptException if the store is corrupt. * @throws IOException if an underlying I/O error occurs. */ - fun read(archive: Int, group: Int): ByteBuf + public fun read(archive: Int, group: Int): ByteBuf /** * Writes a group. If the archive does not exist, it is created first. If a @@ -87,7 +87,7 @@ interface Store : Flushable, Closeable { * @throws StoreFullException if the store is full. * @throws IOException if an underlying I/O error occurs. */ - fun write(archive: Int, group: Int, buf: ByteBuf) + public fun write(archive: Int, group: Int, buf: ByteBuf) /** * Deletes an archive and all groups contained inside it. Does nothing if @@ -96,7 +96,7 @@ interface Store : Flushable, Closeable { * @throws IllegalArgumentException if the archive ID is out of bounds. * @throws IOException if an underlying I/O error occurs. */ - fun remove(archive: Int) + public fun remove(archive: Int) /** * Deletes a group. Does nothing if the archive or group does not exist. @@ -106,17 +106,17 @@ interface Store : Flushable, Closeable { * bounds. * @throws IOException if an underlying I/O error occurs. */ - fun remove(archive: Int, group: Int) + public fun remove(archive: Int, group: Int) - companion object { + public companion object { /** * The maximum archive ID. */ - const val MAX_ARCHIVE = 255 + public const val MAX_ARCHIVE: Int = 255 /** * The maximum length of a group's contents in bytes. */ - const val MAX_GROUP_SIZE = (1 shl 24) - 1 + public const val MAX_GROUP_SIZE: Int = (1 shl 24) - 1 } } diff --git a/cache/src/main/java/dev/openrs2/cache/StoreCorruptException.kt b/cache/src/main/java/dev/openrs2/cache/StoreCorruptException.kt index 84f4dbf06b..7a66b51452 100644 --- a/cache/src/main/java/dev/openrs2/cache/StoreCorruptException.kt +++ b/cache/src/main/java/dev/openrs2/cache/StoreCorruptException.kt @@ -2,4 +2,4 @@ package dev.openrs2.cache import java.io.IOException -class StoreCorruptException(message: String) : IOException(message) +public class StoreCorruptException(message: String) : IOException(message) diff --git a/cache/src/main/java/dev/openrs2/cache/StoreFullException.kt b/cache/src/main/java/dev/openrs2/cache/StoreFullException.kt index 239f835cb3..ca965794a3 100644 --- a/cache/src/main/java/dev/openrs2/cache/StoreFullException.kt +++ b/cache/src/main/java/dev/openrs2/cache/StoreFullException.kt @@ -2,4 +2,4 @@ package dev.openrs2.cache import java.io.IOException -class StoreFullException : IOException() +public class StoreFullException : IOException() diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/CompressCommand.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/CompressCommand.kt index 104781f9d1..d4b653fb18 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/CompressCommand.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/CompressCommand.kt @@ -11,9 +11,9 @@ import dev.openrs2.compress.cli.gzip.GzipCommand import dev.openrs2.compress.cli.lzma.LzmaCommand import dev.openrs2.compress.cli.lzma.UnlzmaCommand -fun main(args: Array) = CompressCommand().main(args) +public fun main(args: Array): Unit = CompressCommand().main(args) -class CompressCommand : NoOpCliktCommand(name = "compress") { +public class CompressCommand : NoOpCliktCommand(name = "compress") { init { subcommands( Bzip2Command(), diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bunzip2Command.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bunzip2Command.kt index 2bb6f56756..a69d561184 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bunzip2Command.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bunzip2Command.kt @@ -8,7 +8,7 @@ import com.github.ajalt.clikt.parameters.types.inputStream import com.github.ajalt.clikt.parameters.types.outputStream import dev.openrs2.compress.bzip2.Bzip2 -class Bunzip2Command : CliktCommand(name = "bunzip2") { +public class Bunzip2Command : CliktCommand(name = "bunzip2") { private val input by option().inputStream().defaultStdin() private val output by option().outputStream().defaultStdout() diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bzip2Command.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bzip2Command.kt index 932fc76b28..0b0f9355b0 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bzip2Command.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/bzip2/Bzip2Command.kt @@ -8,7 +8,7 @@ import com.github.ajalt.clikt.parameters.types.inputStream import com.github.ajalt.clikt.parameters.types.outputStream import dev.openrs2.compress.bzip2.Bzip2 -class Bzip2Command : CliktCommand(name = "bzip2") { +public class Bzip2Command : CliktCommand(name = "bzip2") { private val input by option().inputStream().defaultStdin() private val output by option().outputStream().defaultStdout() diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/DeflateCommand.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/DeflateCommand.kt index e862ce0284..bb3f7cd5f9 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/DeflateCommand.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/DeflateCommand.kt @@ -12,7 +12,7 @@ import com.github.ajalt.clikt.parameters.types.outputStream import java.util.zip.Deflater import java.util.zip.DeflaterOutputStream -class DeflateCommand : CliktCommand(name = "deflate") { +public class DeflateCommand : CliktCommand(name = "deflate") { private val input by option().inputStream().defaultStdin() private val output by option().outputStream().defaultStdout() private val level by option().int().default(Deflater.BEST_COMPRESSION).validate { diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/InflateCommand.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/InflateCommand.kt index aefbb6d47e..433f57beb6 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/InflateCommand.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/deflate/InflateCommand.kt @@ -9,7 +9,7 @@ import com.github.ajalt.clikt.parameters.types.outputStream import java.util.zip.Inflater import java.util.zip.InflaterInputStream -class InflateCommand : CliktCommand(name = "inflate") { +public class InflateCommand : CliktCommand(name = "inflate") { private val input by option().inputStream().defaultStdin() private val output by option().outputStream().defaultStdout() diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GunzipCommand.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GunzipCommand.kt index 5f2e16b4bb..edd67178ed 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GunzipCommand.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GunzipCommand.kt @@ -8,7 +8,7 @@ import com.github.ajalt.clikt.parameters.types.inputStream import com.github.ajalt.clikt.parameters.types.outputStream import dev.openrs2.compress.gzip.Gzip -class GunzipCommand : CliktCommand(name = "gunzip") { +public class GunzipCommand : CliktCommand(name = "gunzip") { private val input by option().inputStream().defaultStdin() private val output by option().outputStream().defaultStdout() diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GzipCommand.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GzipCommand.kt index 86fe92367c..bbd653d2bf 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GzipCommand.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/gzip/GzipCommand.kt @@ -12,7 +12,7 @@ import com.github.ajalt.clikt.parameters.types.outputStream import dev.openrs2.compress.gzip.Gzip import java.util.zip.Deflater -class GzipCommand : CliktCommand(name = "gzip") { +public class GzipCommand : CliktCommand(name = "gzip") { private val input by option().inputStream().defaultStdin() private val output by option().outputStream().defaultStdout() private val level by option().int().default(Deflater.BEST_COMPRESSION).validate { diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/LzmaCommand.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/LzmaCommand.kt index 11aeb02a5e..aad1b45c09 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/LzmaCommand.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/LzmaCommand.kt @@ -12,7 +12,7 @@ import com.github.ajalt.clikt.parameters.types.outputStream import dev.openrs2.compress.lzma.Lzma import org.tukaani.xz.LZMA2Options -class LzmaCommand : CliktCommand(name = "lzma") { +public class LzmaCommand : CliktCommand(name = "lzma") { private val input by option().inputStream().defaultStdin() private val output by option().outputStream().defaultStdout() private val level by option().int().default(LZMA2Options.PRESET_DEFAULT).validate { diff --git a/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/UnlzmaCommand.kt b/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/UnlzmaCommand.kt index 4150c58619..2fb8f1725e 100644 --- a/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/UnlzmaCommand.kt +++ b/compress-cli/src/main/java/dev/openrs2/compress/cli/lzma/UnlzmaCommand.kt @@ -10,7 +10,7 @@ import com.github.ajalt.clikt.parameters.types.long import com.github.ajalt.clikt.parameters.types.outputStream import dev.openrs2.compress.lzma.Lzma -class UnlzmaCommand : CliktCommand(name = "unlzma") { +public class UnlzmaCommand : CliktCommand(name = "unlzma") { private val input by option().inputStream().defaultStdin() private val length by option().long().required() private val output by option().outputStream().defaultStdout() diff --git a/compress/src/main/java/dev/openrs2/compress/bzip2/Bzip2.kt b/compress/src/main/java/dev/openrs2/compress/bzip2/Bzip2.kt index 777683cbe1..64de29cffd 100644 --- a/compress/src/main/java/dev/openrs2/compress/bzip2/Bzip2.kt +++ b/compress/src/main/java/dev/openrs2/compress/bzip2/Bzip2.kt @@ -8,15 +8,15 @@ import java.io.InputStream import java.io.OutputStream import java.io.SequenceInputStream -object Bzip2 { +public object Bzip2 { private const val BLOCK_SIZE = 1 private val HEADER = byteArrayOf('B'.toByte(), 'Z'.toByte(), 'h'.toByte(), ('0' + BLOCK_SIZE).toByte()) - fun createHeaderlessInputStream(input: InputStream): InputStream { + public fun createHeaderlessInputStream(input: InputStream): InputStream { return BZip2CompressorInputStream(SequenceInputStream(ByteArrayInputStream(HEADER), input)) } - fun createHeaderlessOutputStream(output: OutputStream): OutputStream { + public fun createHeaderlessOutputStream(output: OutputStream): OutputStream { return BZip2CompressorOutputStream(SkipOutputStream(output, HEADER.size.toLong()), BLOCK_SIZE) } } diff --git a/compress/src/main/java/dev/openrs2/compress/gzip/Gzip.kt b/compress/src/main/java/dev/openrs2/compress/gzip/Gzip.kt index 8bc8a89e16..2f51f98276 100644 --- a/compress/src/main/java/dev/openrs2/compress/gzip/Gzip.kt +++ b/compress/src/main/java/dev/openrs2/compress/gzip/Gzip.kt @@ -8,14 +8,17 @@ import java.io.SequenceInputStream import java.util.zip.Deflater import java.util.zip.GZIPInputStream -object Gzip { +public object Gzip { private val HEADER = byteArrayOf(0x1F, 0x8B.toByte()) - fun createHeaderlessInputStream(input: InputStream): InputStream { + public fun createHeaderlessInputStream(input: InputStream): InputStream { return GZIPInputStream(SequenceInputStream(ByteArrayInputStream(HEADER), input)) } - fun createHeaderlessOutputStream(output: OutputStream, level: Int = Deflater.BEST_COMPRESSION): OutputStream { + public fun createHeaderlessOutputStream( + output: OutputStream, + level: Int = Deflater.BEST_COMPRESSION + ): OutputStream { return GzipLevelOutputStream(SkipOutputStream(output, HEADER.size.toLong()), level) } } diff --git a/compress/src/main/java/dev/openrs2/compress/gzip/GzipLevelOutputStream.kt b/compress/src/main/java/dev/openrs2/compress/gzip/GzipLevelOutputStream.kt index 2e39df516b..35f3fecffe 100644 --- a/compress/src/main/java/dev/openrs2/compress/gzip/GzipLevelOutputStream.kt +++ b/compress/src/main/java/dev/openrs2/compress/gzip/GzipLevelOutputStream.kt @@ -3,7 +3,7 @@ package dev.openrs2.compress.gzip import java.io.OutputStream import java.util.zip.GZIPOutputStream -class GzipLevelOutputStream(output: OutputStream, level: Int) : GZIPOutputStream(output) { +public class GzipLevelOutputStream(output: OutputStream, level: Int) : GZIPOutputStream(output) { init { def.setLevel(level) } diff --git a/compress/src/main/java/dev/openrs2/compress/lzma/Lzma.kt b/compress/src/main/java/dev/openrs2/compress/lzma/Lzma.kt index 4a985541f5..1eebc5162c 100644 --- a/compress/src/main/java/dev/openrs2/compress/lzma/Lzma.kt +++ b/compress/src/main/java/dev/openrs2/compress/lzma/Lzma.kt @@ -8,12 +8,12 @@ import org.tukaani.xz.LZMAOutputStream import java.io.InputStream import java.io.OutputStream -object Lzma { - val BEST_SPEED = LZMA2Options(LZMA2Options.PRESET_MIN) - val DEFAULT_COMPRESSION = LZMA2Options(LZMA2Options.PRESET_DEFAULT) - val BEST_COMPRESSION = LZMA2Options(LZMA2Options.PRESET_MAX) +public object Lzma { + public val BEST_SPEED: LZMA2Options = LZMA2Options(LZMA2Options.PRESET_MIN) + public val DEFAULT_COMPRESSION: LZMA2Options = LZMA2Options(LZMA2Options.PRESET_DEFAULT) + public val BEST_COMPRESSION: LZMA2Options = LZMA2Options(LZMA2Options.PRESET_MAX) - fun createHeaderlessInputStream(input: InputStream, length: Long): InputStream { + public fun createHeaderlessInputStream(input: InputStream, length: Long): InputStream { val headerInput = LittleEndianDataInputStream(input) val properties = headerInput.readByte() @@ -22,7 +22,7 @@ object Lzma { return LZMAInputStream(input, length, properties, dictionarySize) } - fun createHeaderlessOutputStream(output: OutputStream, options: LZMA2Options): OutputStream { + public fun createHeaderlessOutputStream(output: OutputStream, options: LZMA2Options): OutputStream { val headerOutput = LittleEndianDataOutputStream(output) headerOutput.writeByte((options.pb * 5 + options.lp) * 9 + options.lc) headerOutput.writeInt(options.dictSize) diff --git a/conf/src/main/java/dev/openrs2/conf/Config.kt b/conf/src/main/java/dev/openrs2/conf/Config.kt index 46fd688b53..2bf8b727d0 100644 --- a/conf/src/main/java/dev/openrs2/conf/Config.kt +++ b/conf/src/main/java/dev/openrs2/conf/Config.kt @@ -1,6 +1,6 @@ package dev.openrs2.conf -data class Config( +public data class Config( val game: String, val operator: String, val domain: String diff --git a/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt b/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt index e68c7fc653..82b0b2a3dd 100644 --- a/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt +++ b/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt @@ -4,7 +4,7 @@ import com.google.inject.AbstractModule import com.google.inject.Scopes import dev.openrs2.yaml.YamlModule -object ConfigModule : AbstractModule() { +public object ConfigModule : AbstractModule() { override fun configure() { install(YamlModule) diff --git a/conf/src/main/java/dev/openrs2/conf/ConfigProvider.kt b/conf/src/main/java/dev/openrs2/conf/ConfigProvider.kt index 8481187592..d248ea1b24 100644 --- a/conf/src/main/java/dev/openrs2/conf/ConfigProvider.kt +++ b/conf/src/main/java/dev/openrs2/conf/ConfigProvider.kt @@ -6,7 +6,7 @@ import java.nio.file.Paths import javax.inject.Inject import javax.inject.Provider -class ConfigProvider @Inject constructor(private val mapper: ObjectMapper) : Provider { +public class ConfigProvider @Inject constructor(private val mapper: ObjectMapper) : Provider { override fun get(): Config { if (Files.notExists(CONFIG_PATH)) { Files.copy(EXAMPLE_CONFIG_PATH, CONFIG_PATH) diff --git a/crc32/src/main/java/dev/openrs2/crc32/Crc32Command.kt b/crc32/src/main/java/dev/openrs2/crc32/Crc32Command.kt index 380b6e5aea..b8f114396e 100644 --- a/crc32/src/main/java/dev/openrs2/crc32/Crc32Command.kt +++ b/crc32/src/main/java/dev/openrs2/crc32/Crc32Command.kt @@ -6,9 +6,9 @@ import com.github.ajalt.clikt.parameters.types.defaultStdin import com.github.ajalt.clikt.parameters.types.inputStream import java.util.zip.CRC32 -fun main(args: Array) = Crc32Command().main(args) +public fun main(args: Array): Unit = Crc32Command().main(args) -class Crc32Command : CliktCommand(name = "crc32") { +public class Crc32Command : CliktCommand(name = "crc32") { private val input by option().inputStream().defaultStdin() override fun run() { diff --git a/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt b/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt index 47cbce1a01..f71025dac4 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt @@ -4,7 +4,7 @@ import com.google.inject.AbstractModule import com.google.inject.Scopes import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters -object CryptoModule : AbstractModule() { +public object CryptoModule : AbstractModule() { override fun configure() { bind(RSAPrivateCrtKeyParameters::class.java) .toProvider(RsaKeyProvider::class.java) diff --git a/crypto/src/main/java/dev/openrs2/crypto/IsaacRandom.kt b/crypto/src/main/java/dev/openrs2/crypto/IsaacRandom.kt index 78c3bd3606..165486dd8e 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/IsaacRandom.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/IsaacRandom.kt @@ -1,6 +1,6 @@ package dev.openrs2.crypto -class IsaacRandom { +public class IsaacRandom { private var count = 0 private val rsl: IntArray private val mem = IntArray(SIZE) @@ -8,12 +8,12 @@ class IsaacRandom { private var b = 0 private var c = 0 - constructor() { + public constructor() { rsl = IntArray(SIZE) init(false) } - constructor(seed: IntArray) { + public constructor(seed: IntArray) { require(seed.size <= SIZE) rsl = seed.copyOf(SIZE) @@ -257,7 +257,7 @@ class IsaacRandom { this.a = a } - fun nextInt(): Int { + public fun nextInt(): Int { if (count-- == 0) { isaac() count = SIZE - 1 diff --git a/crypto/src/main/java/dev/openrs2/crypto/Pkcs12KeyStore.kt b/crypto/src/main/java/dev/openrs2/crypto/Pkcs12KeyStore.kt index 087a309671..415baf0aa6 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/Pkcs12KeyStore.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/Pkcs12KeyStore.kt @@ -23,20 +23,20 @@ import java.time.ZoneOffset import java.util.Date import java.util.jar.JarFile -class Pkcs12KeyStore private constructor(privateKeyEntry: KeyStore.PrivateKeyEntry, signerName: String) { +public class Pkcs12KeyStore private constructor(privateKeyEntry: KeyStore.PrivateKeyEntry, signerName: String) { private val signer = JarSigner.Builder(privateKeyEntry) .signatureAlgorithm("SHA256withRSA") .digestAlgorithm("SHA-256") .signerName(signerName) .build() - fun signJar(input: Path, output: OutputStream) { + public fun signJar(input: Path, output: OutputStream) { JarFile(input.toFile()).use { file -> signer.sign(file, output) } } - companion object { + public companion object { private const val ALIAS = "openrs2" private const val PASSWORD = ALIAS @@ -51,7 +51,7 @@ class Pkcs12KeyStore private constructor(privateKeyEntry: KeyStore.PrivateKeyEnt private val SHA256_WITH_RSA = AlgorithmIdentifier(PKCSObjectIdentifiers.sha256WithRSAEncryption) private val SHA256 = AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256) - fun open(path: Path, signerName: String): Pkcs12KeyStore { + public fun open(path: Path, signerName: String): Pkcs12KeyStore { val keyStore = KeyStore.getInstance("PKCS12") if (Files.exists(path)) { Files.newInputStream(path).use { input -> diff --git a/crypto/src/main/java/dev/openrs2/crypto/Rsa.kt b/crypto/src/main/java/dev/openrs2/crypto/Rsa.kt index c42ced041d..781ea3bf68 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/Rsa.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/Rsa.kt @@ -28,7 +28,7 @@ import java.nio.file.Path import java.security.spec.KeySpec import java.security.spec.RSAPrivateCrtKeySpec -val RSAPrivateCrtKeyParameters.publicKey +public val RSAPrivateCrtKeyParameters.publicKey: RSAKeyParameters get() = RSAKeyParameters(false, modulus, publicExponent) private fun ByteBuf.toBigInteger(): BigInteger { @@ -40,19 +40,19 @@ private fun BigInteger.toByteBuf(): ByteBuf { return Unpooled.wrappedBuffer(toByteArray()) } -fun ByteBuf.rsaEncrypt(key: RSAKeyParameters): ByteBuf { +public fun ByteBuf.rsaEncrypt(key: RSAKeyParameters): ByteBuf { return Rsa.encrypt(toBigInteger(), key).toByteBuf() } -fun ByteBuf.rsaDecrypt(key: RSAKeyParameters): ByteBuf { +public fun ByteBuf.rsaDecrypt(key: RSAKeyParameters): ByteBuf { return Rsa.decrypt(toBigInteger(), key).toByteBuf() } -fun RSAPrivateCrtKeyParameters.toKeySpec(): KeySpec { +public fun RSAPrivateCrtKeyParameters.toKeySpec(): KeySpec { return RSAPrivateCrtKeySpec(modulus, publicExponent, exponent, p, q, dp, dq, qInv) } -object Rsa { +public object Rsa { private const val PUBLIC_KEY = "PUBLIC KEY" private const val PRIVATE_KEY = "PRIVATE KEY" @@ -66,14 +66,14 @@ object Rsa { * The maximum output length of RSA encryption is the key size plus one, so * the maximum key size supported by the client is 126 bytes - or 1008 bits. */ - const val CLIENT_KEY_LENGTH = 1008 + public const val CLIENT_KEY_LENGTH: Int = 1008 - const val JAR_KEY_LENGTH = 2048 + public const val JAR_KEY_LENGTH: Int = 2048 // 1 in 2^80 private const val CERTAINTY = 80 - fun generateKeyPair(length: Int): Pair { + public fun generateKeyPair(length: Int): Pair { val generator = RSAKeyPairGenerator() generator.init(RSAKeyGenerationParameters(F4, secureRandom, length, CERTAINTY)) @@ -81,7 +81,7 @@ object Rsa { return Pair(keyPair.public as RSAKeyParameters, keyPair.private as RSAPrivateCrtKeyParameters) } - fun encrypt(plaintext: BigInteger, key: RSAKeyParameters): BigInteger { + public fun encrypt(plaintext: BigInteger, key: RSAKeyParameters): BigInteger { require(!key.isPrivate) return plaintext.modPow(key.exponent, key.modulus) } @@ -100,7 +100,7 @@ object Rsa { } } - fun decrypt(ciphertext: BigInteger, key: RSAKeyParameters): BigInteger { + public fun decrypt(ciphertext: BigInteger, key: RSAKeyParameters): BigInteger { require(key.isPrivate) if (key is RSAPrivateCrtKeyParameters) { @@ -137,7 +137,7 @@ object Rsa { } } - fun readPublicKey(path: Path): RSAKeyParameters { + public fun readPublicKey(path: Path): RSAKeyParameters { val der = readSinglePemObject(path, PUBLIC_KEY) val spki = SubjectPublicKeyInfo.getInstance(der) @@ -147,12 +147,12 @@ object Rsa { return RSAKeyParameters(false, key.modulus, key.publicExponent) } - fun writePublicKey(path: Path, key: RSAKeyParameters) { + public fun writePublicKey(path: Path, key: RSAKeyParameters) { val spki = SubjectPublicKeyInfoFactory.createSubjectPublicKeyInfo(key) return writeSinglePemObject(path, PUBLIC_KEY, spki.encoded) } - fun readPrivateKey(path: Path): RSAPrivateCrtKeyParameters { + public fun readPrivateKey(path: Path): RSAPrivateCrtKeyParameters { val der = readSinglePemObject(path, PRIVATE_KEY) val pki = PrivateKeyInfo.getInstance(der) @@ -171,7 +171,7 @@ object Rsa { ) } - fun writePrivateKey(path: Path, key: RSAKeyParameters) { + public fun writePrivateKey(path: Path, key: RSAKeyParameters) { val pki = PrivateKeyInfoFactory.createPrivateKeyInfo(key) return writeSinglePemObject(path, PRIVATE_KEY, pki.encoded) } diff --git a/crypto/src/main/java/dev/openrs2/crypto/RsaKeyProvider.kt b/crypto/src/main/java/dev/openrs2/crypto/RsaKeyProvider.kt index f6a2b2f864..bc36df5818 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/RsaKeyProvider.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/RsaKeyProvider.kt @@ -5,7 +5,7 @@ import java.nio.file.Files import java.nio.file.Paths import javax.inject.Provider -class RsaKeyProvider : Provider { +public class RsaKeyProvider : Provider { override fun get(): RSAPrivateCrtKeyParameters { return if (Files.exists(PATH)) { Rsa.readPrivateKey(PATH) diff --git a/crypto/src/main/java/dev/openrs2/crypto/ThreadLocalSecureRandom.kt b/crypto/src/main/java/dev/openrs2/crypto/ThreadLocalSecureRandom.kt index 57a90d628f..017f7a6552 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/ThreadLocalSecureRandom.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/ThreadLocalSecureRandom.kt @@ -4,5 +4,5 @@ import java.security.SecureRandom private val threadLocal = ThreadLocal.withInitial { SecureRandom() } -val secureRandom: SecureRandom +public val secureRandom: SecureRandom get() = threadLocal.get() diff --git a/crypto/src/main/java/dev/openrs2/crypto/Whirlpool.kt b/crypto/src/main/java/dev/openrs2/crypto/Whirlpool.kt index 2b043f2842..076ee0b4fa 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/Whirlpool.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/Whirlpool.kt @@ -1,6 +1,6 @@ package dev.openrs2.crypto -class Whirlpool { +public class Whirlpool { private val bitLength = ByteArray(32) private val buffer = ByteArray(64) private var bufferBits = 0 @@ -67,7 +67,7 @@ class Whirlpool { } } - fun NESSIEinit() { + public fun NESSIEinit() { bitLength.fill(0) bufferBits = 0 bufferPos = 0 @@ -75,7 +75,7 @@ class Whirlpool { hash.fill(0) } - fun NESSIEadd(source: ByteArray, bits: Long) { + public fun NESSIEadd(source: ByteArray, bits: Long) { var sourceBits = bits var sourcePos = 0 val sourceGap = (8 - (sourceBits.toInt() and 7)) and 7 @@ -138,7 +138,7 @@ class Whirlpool { } } - fun NESSIEfinalize(digest: ByteArray) { + public fun NESSIEfinalize(digest: ByteArray) { buffer[bufferPos] = (buffer[bufferPos].toInt() or (0x80 ushr (bufferBits and 7))).toByte() bufferPos++ @@ -173,7 +173,7 @@ class Whirlpool { } } - companion object { + public companion object { private const val DIGESTBITS = 512 private const val DIGESTBYTES = DIGESTBITS ushr 3 private const val R = 10 @@ -248,7 +248,7 @@ class Whirlpool { } } - fun whirlpool(data: ByteArray, off: Int = 0, len: Int = data.size): ByteArray { + public fun whirlpool(data: ByteArray, off: Int = 0, len: Int = data.size): ByteArray { val source: ByteArray if (off <= 0) { source = data diff --git a/crypto/src/main/java/dev/openrs2/crypto/Xtea.kt b/crypto/src/main/java/dev/openrs2/crypto/Xtea.kt index a00fffebb3..ccb881aad3 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/Xtea.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/Xtea.kt @@ -7,20 +7,20 @@ private const val ROUNDS = 32 private const val BLOCK_SIZE = 8 private const val BLOCK_SIZE_MASK = BLOCK_SIZE - 1 -class XteaKey( +public class XteaKey( private val k0: Int, private val k1: Int, private val k2: Int, private val k3: Int ) { - val isZero: Boolean + public val isZero: Boolean get() = k0 == 0 && k1 == 0 && k2 == 0 && k3 == 0 - fun toIntArray(): IntArray { + public fun toIntArray(): IntArray { return intArrayOf(k0, k1, k2, k3) } - fun toHex(): String { + public fun toHex(): String { return Integer.toUnsignedString(k0, 16).padStart(8, '0') + Integer.toUnsignedString(k1, 16).padStart(8, '0') + Integer.toUnsignedString(k2, 16).padStart(8, '0') + @@ -31,16 +31,16 @@ class XteaKey( return toHex() } - companion object { - val ZERO = XteaKey(0, 0, 0, 0) + public companion object { + public val ZERO: XteaKey = XteaKey(0, 0, 0, 0) - fun fromIntArray(a: IntArray): XteaKey { + public fun fromIntArray(a: IntArray): XteaKey { require(a.size == 4) return XteaKey(a[0], a[1], a[2], a[3]) } - fun fromHex(s: String): XteaKey { + public fun fromHex(s: String): XteaKey { require(s.length == 32) val k0 = Integer.parseUnsignedInt(s, 0, 8, 16) @@ -53,7 +53,7 @@ class XteaKey( } } -fun ByteBuf.xteaEncrypt(index: Int, length: Int, key: XteaKey) { +public fun ByteBuf.xteaEncrypt(index: Int, length: Int, key: XteaKey) { val k = key.toIntArray() val end = index + (length and BLOCK_SIZE_MASK.inv()) @@ -73,7 +73,7 @@ fun ByteBuf.xteaEncrypt(index: Int, length: Int, key: XteaKey) { } } -fun ByteBuf.xteaDecrypt(index: Int, length: Int, key: XteaKey) { +public fun ByteBuf.xteaDecrypt(index: Int, length: Int, key: XteaKey) { val k = key.toIntArray() val end = index + (length and BLOCK_SIZE_MASK.inv()) diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt b/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt index e425476811..8ae3ff0fb2 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt @@ -3,9 +3,9 @@ package dev.openrs2.decompiler import com.github.ajalt.clikt.core.CliktCommand import dev.openrs2.deob.util.Module -fun main(args: Array) = DecompileCommand().main(args) +public fun main(args: Array): Unit = DecompileCommand().main(args) -class DecompileCommand : CliktCommand(name = "decompile") { +public class DecompileCommand : CliktCommand(name = "decompile") { override fun run() { val decompiler = Decompiler(Module.ALL) decompiler.run() diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt b/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt index 0e21cf8e1e..e52715d9da 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt @@ -4,8 +4,8 @@ import dev.openrs2.deob.util.Module import org.jetbrains.java.decompiler.main.Fernflower import org.jetbrains.java.decompiler.main.extern.IFernflowerPreferences -class Decompiler(private val modules: Set) { - fun run() { +public class Decompiler(private val modules: Set) { + public fun run() { for (module in modules) { DecompilerIo(module.sources).use { io -> val fernflower = Fernflower(io, io, OPTIONS, Slf4jFernflowerLogger) diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt b/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt index 26327e4214..17c458ab1d 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/DecompilerIo.kt @@ -9,7 +9,7 @@ import java.nio.file.Path import java.util.jar.JarFile import java.util.jar.Manifest -class DecompilerIo(private val destination: Path) : IBytecodeProvider, IResultSaver, Closeable { +public class DecompilerIo(private val destination: Path) : IBytecodeProvider, IResultSaver, Closeable { private val inputJars = mutableMapOf() override fun getBytecode(externalPath: String, internalPath: String?): ByteArray { diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/Library.kt b/decompiler/src/main/java/dev/openrs2/decompiler/Library.kt index 49615764e9..d350f49b16 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/Library.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/Library.kt @@ -2,8 +2,8 @@ package dev.openrs2.decompiler import java.nio.file.Path -class Library( - val source: Path, - val destination: Path, - val dependencies: List = emptyList() +public class Library( + public val source: Path, + public val destination: Path, + public val dependencies: List = emptyList() ) diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.kt b/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.kt index 3d2f11123d..a264655aec 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/Slf4jFernflowerLogger.kt @@ -3,7 +3,7 @@ package dev.openrs2.decompiler import com.github.michaelbull.logging.InlineLogger import org.jetbrains.java.decompiler.main.extern.IFernflowerLogger -object Slf4jFernflowerLogger : IFernflowerLogger() { +public object Slf4jFernflowerLogger : IFernflowerLogger() { private val logger = InlineLogger() override fun startClass(className: String) { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt index f0749b7526..7b3225db60 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt @@ -7,10 +7,10 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class AstDeobfuscator @Inject constructor( +public class AstDeobfuscator @Inject constructor( private val transformers: Set<@JvmSuppressWildcards Transformer> ) { - fun run(modules: Set) { + public fun run(modules: Set) { val group = LibraryGroup(modules.map(Library.Companion::parse)) for (transformer in transformers) { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscatorModule.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscatorModule.kt index c00311d9c6..01a943821b 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscatorModule.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscatorModule.kt @@ -26,7 +26,7 @@ import dev.openrs2.deob.ast.transform.Transformer import dev.openrs2.deob.ast.transform.UnencloseTransformer import dev.openrs2.deob.ast.transform.ValueOfTransformer -object AstDeobfuscatorModule : AbstractModule() { +public object AstDeobfuscatorModule : AbstractModule() { override fun configure() { bind(GlRegistry::class.java) .toProvider(GlRegistryProvider::class.java) diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/DeobfuscateAstCommand.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/DeobfuscateAstCommand.kt index 209774d687..cebcc19cf8 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/DeobfuscateAstCommand.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/DeobfuscateAstCommand.kt @@ -4,9 +4,9 @@ import com.github.ajalt.clikt.core.CliktCommand import com.google.inject.Guice import dev.openrs2.deob.util.Module -fun main(args: Array) = DeobfuscateAstCommand().main(args) +public fun main(args: Array): Unit = DeobfuscateAstCommand().main(args) -class DeobfuscateAstCommand : CliktCommand(name = "deob-ast") { +public class DeobfuscateAstCommand : CliktCommand(name = "deob-ast") { override fun run() { val injector = Guice.createInjector(AstDeobfuscatorModule) val deobfuscator = injector.getInstance(AstDeobfuscator::class.java) diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/Library.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/Library.kt index 657153d97f..b49646fa5e 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/Library.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/Library.kt @@ -13,8 +13,8 @@ import com.github.michaelbull.logging.InlineLogger import dev.openrs2.deob.util.Module import java.util.function.Function -class Library( - val name: String, +public class Library( + public val name: String, private val root: SourceRoot ) : Iterable { private val units = mutableMapOf() @@ -26,7 +26,7 @@ class Library( } } - operator fun get(name: String): CompilationUnit? { + public operator fun get(name: String): CompilationUnit? { return units[name] } @@ -34,12 +34,12 @@ class Library( return units.values.iterator() } - fun save() { + public fun save() { logger.info { "Saving root ${root.root}" } root.saveAll() } - companion object { + public companion object { private val logger = InlineLogger() private val PC_ANNOTATION_REGEX = Regex("@Pc\\(([0-9]+)\\)\\s+") @@ -54,7 +54,7 @@ class Library( )::print ).andThen(::stripNewlineAfterPcAnnotation) - fun parse(module: Module): Library { + public fun parse(module: Module): Library { logger.info { "Parsing root ${module.sources}" } val solver = CombinedTypeSolver( diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/LibraryGroup.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/LibraryGroup.kt index 5482ab8616..77acf68694 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/LibraryGroup.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/LibraryGroup.kt @@ -1,9 +1,9 @@ package dev.openrs2.deob.ast -class LibraryGroup(libraries: Iterable) : Iterable { +public class LibraryGroup(libraries: Iterable) : Iterable { private val libraries = libraries.associateBy { it.name } - operator fun get(name: String): Library? { + public operator fun get(name: String): Library? { return libraries[name] } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt index 2e3d2e78f2..05ecf0707a 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistry.kt @@ -5,16 +5,16 @@ import com.google.common.collect.ImmutableSetMultimap import org.jdom2.input.SAXBuilder import java.io.InputStream -data class GlEnum(val name: String, val value: Long) +public data class GlEnum(val name: String, val value: Long) -data class GlGroup(val name: String, val enums: List) +public data class GlGroup(val name: String, val enums: List) -data class GlParameter(val name: String, val bitfield: Boolean, val group: GlGroup?) +public data class GlParameter(val name: String, val bitfield: Boolean, val group: GlGroup?) -data class GlCommand(val name: String, val parameters: List) +public data class GlCommand(val name: String, val parameters: List) -data class GlRegistry(val enums: ImmutableSetMultimap, val commands: Map) { - companion object { +public data class GlRegistry(val enums: ImmutableSetMultimap, val commands: Map) { + public companion object { private fun parseValue(s: String): Long { return if (s.startsWith("0x")) { java.lang.Long.parseUnsignedLong(s.substring(2), 16) @@ -23,7 +23,7 @@ data class GlRegistry(val enums: ImmutableSetMultimap, val command } } - fun parse(input: InputStream): GlRegistry { + public fun parse(input: InputStream): GlRegistry { val root = SAXBuilder().build(input).rootElement // create enums and groups diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistryProvider.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistryProvider.kt index af014346c3..b4dd602159 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistryProvider.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/gl/GlRegistryProvider.kt @@ -4,14 +4,14 @@ import java.nio.file.Files import java.nio.file.Paths import javax.inject.Provider -class GlRegistryProvider : Provider { +public class GlRegistryProvider : Provider { override fun get(): GlRegistry { return Files.newInputStream(PATH).use { input -> GlRegistry.parse(input) } } - companion object { + private companion object { private val PATH = Paths.get("share/deob/gl.xml") } } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt index 2ee4dc2642..0da53e8067 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/AddSubTransformer.kt @@ -16,7 +16,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class AddSubTransformer : Transformer() { +public class AddSubTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: BinaryExpr -> val op = expr.operator diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt index 47127484de..450ca38e20 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BinaryExprOrderTransformer.kt @@ -13,7 +13,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class BinaryExprOrderTransformer : Transformer() { +public class BinaryExprOrderTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: BinaryExpr -> val op = expr.operator.flip() ?: return@walk diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt index 301ddfd18e..1938ade941 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt @@ -13,7 +13,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class BitMaskTransformer : Transformer() { +public class BitMaskTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { /* * Transform: diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/CharLiteralTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/CharLiteralTransformer.kt index 686e29b342..0cec6fe1d5 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/CharLiteralTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/CharLiteralTransformer.kt @@ -28,7 +28,7 @@ import java.lang.Character.UNASSIGNED import javax.inject.Singleton @Singleton -class CharLiteralTransformer : Transformer() { +public class CharLiteralTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: BinaryExpr -> if (expr.operator in COMPARISON_OPERATORS) { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ComplementTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ComplementTransformer.kt index 054a5d6724..185a58bc11 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ComplementTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ComplementTransformer.kt @@ -16,7 +16,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class ComplementTransformer : Transformer() { +public class ComplementTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: BinaryExpr -> val op = complement(expr.operator) ?: return@walk diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/EncloseTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/EncloseTransformer.kt index ffd3bc7cc1..f9fdee4488 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/EncloseTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/EncloseTransformer.kt @@ -20,7 +20,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class EncloseTransformer : Transformer() { +public class EncloseTransformer : Transformer() { private enum class Associativity { LEFT, RIGHT, diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ForLoopConditionTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ForLoopConditionTransformer.kt index fb6109b560..b4e4050923 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ForLoopConditionTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ForLoopConditionTransformer.kt @@ -18,7 +18,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class ForLoopConditionTransformer : Transformer() { +public class ForLoopConditionTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { stmt: ForStmt -> val updatedExprs = stmt.update.mapNotNull { it.getUpdatedExpr() } diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlTransformer.kt index 96037743d9..8d55d9164e 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlTransformer.kt @@ -35,7 +35,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class GlTransformer @Inject constructor(private val registry: GlRegistry) : Transformer() { +public class GlTransformer @Inject constructor(private val registry: GlRegistry) : Transformer() { private val enums = mutableSetOf() private var glUnit: CompilationUnit? = null diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/HexLiteralTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/HexLiteralTransformer.kt index 868ccd1c0c..b3eb535076 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/HexLiteralTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/HexLiteralTransformer.kt @@ -14,7 +14,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class HexLiteralTransformer : Transformer() { +public class HexLiteralTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: BinaryExpr -> if (expr.operator in SHIFT_OPS) { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IdentityTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IdentityTransformer.kt index 414ff553a3..aab7290abb 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IdentityTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IdentityTransformer.kt @@ -14,7 +14,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class IdentityTransformer : Transformer() { +public class IdentityTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: BinaryExpr -> @Suppress("NON_EXHAUSTIVE_WHEN") diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IfElseTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IfElseTransformer.kt index 7f70e1cdf4..985316b8eb 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IfElseTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IfElseTransformer.kt @@ -19,7 +19,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class IfElseTransformer : Transformer() { +public class IfElseTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { var oldUnit: CompilationUnit do { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IncrementTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IncrementTransformer.kt index 7a4139dd90..b35812c7d4 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IncrementTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/IncrementTransformer.kt @@ -10,7 +10,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class IncrementTransformer : Transformer() { +public class IncrementTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { stmt: ExpressionStmt -> val expr = stmt.expression diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt index 1f2f4b23d4..55626acd8b 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NegativeLiteralTransformer.kt @@ -10,7 +10,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class NegativeLiteralTransformer : Transformer() { +public class NegativeLiteralTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: UnaryExpr -> val operand = expr.expression diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NewInstanceTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NewInstanceTransformer.kt index 43a1a6cb61..07999f403a 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NewInstanceTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NewInstanceTransformer.kt @@ -9,7 +9,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class NewInstanceTransformer : Transformer() { +public class NewInstanceTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: MethodCallExpr -> if (expr.nameAsString != "newInstance") { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NotTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NotTransformer.kt index bdc5baf119..204dccce19 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NotTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NotTransformer.kt @@ -15,7 +15,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class NotTransformer : Transformer() { +public class NotTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: BinaryExpr -> val op = expr.operator.flip() ?: return@walk diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/RedundantCastTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/RedundantCastTransformer.kt index 7a6bf9cb57..1d772324c8 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/RedundantCastTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/RedundantCastTransformer.kt @@ -25,7 +25,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class RedundantCastTransformer : Transformer() { +public class RedundantCastTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { // remove double casts unit.walk { expr: CastExpr -> diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/TernaryTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/TernaryTransformer.kt index dcd0610e6e..8a5f817317 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/TernaryTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/TernaryTransformer.kt @@ -10,7 +10,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class TernaryTransformer : Transformer() { +public class TernaryTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: ConditionalExpr -> val condition = expr.condition diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/Transformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/Transformer.kt index 5375bdf7cb..a858e07368 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/Transformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/Transformer.kt @@ -4,8 +4,8 @@ import com.github.javaparser.ast.CompilationUnit import dev.openrs2.deob.ast.Library import dev.openrs2.deob.ast.LibraryGroup -abstract class Transformer { - fun transform(group: LibraryGroup) { +public abstract class Transformer { + public fun transform(group: LibraryGroup) { preTransform(group) for (library in group) { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/UnencloseTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/UnencloseTransformer.kt index 926b316e21..0275360cf0 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/UnencloseTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/UnencloseTransformer.kt @@ -8,7 +8,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class UnencloseTransformer : Transformer() { +public class UnencloseTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: EnclosedExpr -> expr.replace(expr.inner.clone()) diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt index 7c25f30709..3ac58478f4 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ValueOfTransformer.kt @@ -10,7 +10,7 @@ import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @Singleton -class ValueOfTransformer : Transformer() { +public class ValueOfTransformer : Transformer() { override fun transformUnit(group: LibraryGroup, library: Library, unit: CompilationUnit) { unit.walk { expr: ObjectCreationExpr -> if (expr.type.isBoxedType) { diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt index 0ab02dec61..1b39d06aba 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/ExprUtils.kt @@ -12,7 +12,7 @@ import com.github.javaparser.ast.expr.NameExpr import com.github.javaparser.ast.expr.ThisExpr import com.github.javaparser.ast.expr.UnaryExpr -fun IntegerLiteralExpr.checkedAsInt(): Int { +public fun IntegerLiteralExpr.checkedAsInt(): Int { val n = asNumber() if (n !is Int) { error("Invalid IntegerLiteralExpr type") @@ -20,11 +20,11 @@ fun IntegerLiteralExpr.checkedAsInt(): Int { return n } -fun Int.toHexLiteralExpr(): IntegerLiteralExpr { +public fun Int.toHexLiteralExpr(): IntegerLiteralExpr { return IntegerLiteralExpr("0x${Integer.toUnsignedString(this, 16).toUpperCase()}") } -fun LongLiteralExpr.checkedAsLong(): Long { +public fun LongLiteralExpr.checkedAsLong(): Long { val n = asNumber() if (n !is Long) { error("Invalid LongLiteralExpr type") @@ -32,19 +32,19 @@ fun LongLiteralExpr.checkedAsLong(): Long { return n } -fun Long.toHexLiteralExpr(): LongLiteralExpr { +public fun Long.toHexLiteralExpr(): LongLiteralExpr { return LongLiteralExpr("0x${java.lang.Long.toUnsignedString(this, 16).toUpperCase()}L") } -fun Expression.isIntegerOrLongLiteral(): Boolean { +public fun Expression.isIntegerOrLongLiteral(): Boolean { return this is IntegerLiteralExpr || this is LongLiteralExpr } -fun Long.toLongLiteralExpr(): LongLiteralExpr { +public fun Long.toLongLiteralExpr(): LongLiteralExpr { return LongLiteralExpr(this.toString() + "L") } -fun Expression.negate(): Expression { +public fun Expression.negate(): Expression { return when (this) { is UnaryExpr -> when (operator) { UnaryExpr.Operator.PLUS -> UnaryExpr(expression.clone(), UnaryExpr.Operator.MINUS) @@ -65,7 +65,7 @@ fun Expression.negate(): Expression { } } -fun Expression.not(): Expression { +public fun Expression.not(): Expression { when (this) { is UnaryExpr -> { if (operator == UnaryExpr.Operator.LOGICAL_COMPLEMENT) { @@ -99,7 +99,7 @@ fun Expression.not(): Expression { return UnaryExpr(clone(), UnaryExpr.Operator.LOGICAL_COMPLEMENT) } -fun Expression.countNots(): Int { +public fun Expression.countNots(): Int { var count = 0 if (this is UnaryExpr && operator == UnaryExpr.Operator.LOGICAL_COMPLEMENT) { @@ -117,7 +117,7 @@ fun Expression.countNots(): Int { return count } -fun Expression.hasSideEffects(): Boolean { +public fun Expression.hasSideEffects(): Boolean { return when (this) { is LiteralExpr, is NameExpr, is ThisExpr -> false is UnaryExpr -> expression.hasSideEffects() @@ -129,7 +129,7 @@ fun Expression.hasSideEffects(): Boolean { } } -fun BinaryExpr.Operator.flip(): BinaryExpr.Operator? { +public fun BinaryExpr.Operator.flip(): BinaryExpr.Operator? { return when (this) { BinaryExpr.Operator.PLUS, BinaryExpr.Operator.MULTIPLY -> this BinaryExpr.Operator.EQUALS, BinaryExpr.Operator.NOT_EQUALS -> this diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/NodeUtils.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/NodeUtils.kt index 2cae102e0f..035b4f55e2 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/NodeUtils.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/NodeUtils.kt @@ -2,7 +2,7 @@ package dev.openrs2.deob.ast.util import com.github.javaparser.ast.Node -inline fun Node.walk(crossinline consumer: (T) -> Unit) { +public inline fun Node.walk(crossinline consumer: (T) -> Unit) { this.walk(Node.TreeTraversal.POSTORDER) { if (it is T) { consumer(it) diff --git a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.kt b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.kt index a0a12a39d4..190f172013 100644 --- a/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.kt +++ b/deob-ast/src/main/java/dev/openrs2/deob/ast/util/TypeUtils.kt @@ -2,10 +2,10 @@ package dev.openrs2.deob.ast.util import com.github.javaparser.resolution.types.ResolvedType -fun ResolvedType.isString(): Boolean { +public fun ResolvedType.isString(): Boolean { return isReferenceType && asReferenceType().qualifiedName == "java.lang.String" } -fun ResolvedType.isClass(): Boolean { +public fun ResolvedType.isClass(): Boolean { return isReferenceType && asReferenceType().qualifiedName == "java.lang.Class" } diff --git a/deob-processor/src/main/java/dev/openrs2/deob/processor/DeobfuscatorProcessorModule.kt b/deob-processor/src/main/java/dev/openrs2/deob/processor/DeobfuscatorProcessorModule.kt index 2ca07ba44f..0ad605061e 100644 --- a/deob-processor/src/main/java/dev/openrs2/deob/processor/DeobfuscatorProcessorModule.kt +++ b/deob-processor/src/main/java/dev/openrs2/deob/processor/DeobfuscatorProcessorModule.kt @@ -4,7 +4,7 @@ import com.google.inject.AbstractModule import dev.openrs2.deob.util.DeobfuscatorUtilModule import dev.openrs2.yaml.YamlModule -object DeobfuscatorProcessorModule : AbstractModule() { +public object DeobfuscatorProcessorModule : AbstractModule() { override fun configure() { install(DeobfuscatorUtilModule) install(YamlModule) diff --git a/deob-processor/src/main/java/dev/openrs2/deob/processor/LocalVariableScanner.kt b/deob-processor/src/main/java/dev/openrs2/deob/processor/LocalVariableScanner.kt index 16f018f02c..2919b9c442 100644 --- a/deob-processor/src/main/java/dev/openrs2/deob/processor/LocalVariableScanner.kt +++ b/deob-processor/src/main/java/dev/openrs2/deob/processor/LocalVariableScanner.kt @@ -5,7 +5,7 @@ import com.sun.source.util.TreePathScanner import com.sun.source.util.Trees import dev.openrs2.deob.annotation.Pc -class LocalVariableScanner(private val trees: Trees) : TreePathScanner>() { +public class LocalVariableScanner(private val trees: Trees) : TreePathScanner>() { override fun visitVariable(node: VariableTree, p: MutableMap): Void? { val element = trees.getElement(currentPath) diff --git a/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt b/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt index 0ef84f2754..64fddbcf30 100644 --- a/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt +++ b/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt @@ -37,7 +37,7 @@ import javax.lang.model.element.VariableElement @SupportedOptions( "map" ) -class NameMapProcessor : AbstractProcessor() { +public class NameMapProcessor : AbstractProcessor() { private val map = NameMap() private val mapper: ObjectMapper private lateinit var trees: Trees diff --git a/deob-util/src/main/java/dev/openrs2/deob/util/DeobfuscatorUtilModule.kt b/deob-util/src/main/java/dev/openrs2/deob/util/DeobfuscatorUtilModule.kt index c7b191ecc6..7ae38d918b 100644 --- a/deob-util/src/main/java/dev/openrs2/deob/util/DeobfuscatorUtilModule.kt +++ b/deob-util/src/main/java/dev/openrs2/deob/util/DeobfuscatorUtilModule.kt @@ -6,7 +6,7 @@ import dev.openrs2.asm.AsmModule import dev.openrs2.deob.util.map.NameMap import dev.openrs2.deob.util.map.NameMapProvider -object DeobfuscatorUtilModule : AbstractModule() { +public object DeobfuscatorUtilModule : AbstractModule() { override fun configure() { install(AsmModule) diff --git a/deob-util/src/main/java/dev/openrs2/deob/util/Module.kt b/deob-util/src/main/java/dev/openrs2/deob/util/Module.kt index eea088ced2..ce78223811 100644 --- a/deob-util/src/main/java/dev/openrs2/deob/util/Module.kt +++ b/deob-util/src/main/java/dev/openrs2/deob/util/Module.kt @@ -3,12 +3,13 @@ package dev.openrs2.deob.util import java.nio.file.Path import java.nio.file.Paths -class Module(val name: String, val dependencies: Set = emptySet()) { - val jar: Path = Paths.get("nonfree/var/cache/deob").resolve("$name.jar") - val sources: Path = Paths.get("nonfree").resolve(name).resolve("src/main/java") - val transitiveDependencies: Set = dependencies.plus(dependencies.flatMap { it.transitiveDependencies }) +public class Module(public val name: String, public val dependencies: Set = emptySet()) { + public val jar: Path = Paths.get("nonfree/var/cache/deob").resolve("$name.jar") + public val sources: Path = Paths.get("nonfree").resolve(name).resolve("src/main/java") + public val transitiveDependencies: Set = + dependencies.plus(dependencies.flatMap { it.transitiveDependencies }) - companion object { + public companion object { private val GL = Module("gl") private val SIGNLINK = Module("signlink") private val UNPACK = Module("unpack") @@ -16,6 +17,6 @@ class Module(val name: String, val dependencies: Set = emptySet()) { private val LOADER = Module("loader", setOf(SIGNLINK, UNPACK)) private val UNPACKCLASS = Module("unpackclass", setOf(UNPACK)) - val ALL = setOf(CLIENT, GL, LOADER, SIGNLINK, UNPACK, UNPACKCLASS) + public val ALL: Set = setOf(CLIENT, GL, LOADER, SIGNLINK, UNPACK, UNPACKCLASS) } } diff --git a/deob-util/src/main/java/dev/openrs2/deob/util/map/Field.kt b/deob-util/src/main/java/dev/openrs2/deob/util/map/Field.kt index 81afa0bf0a..b94c844fa0 100644 --- a/deob-util/src/main/java/dev/openrs2/deob/util/map/Field.kt +++ b/deob-util/src/main/java/dev/openrs2/deob/util/map/Field.kt @@ -1,3 +1,3 @@ package dev.openrs2.deob.util.map -data class Field(val owner: String, val name: String) +public data class Field(val owner: String, val name: String) diff --git a/deob-util/src/main/java/dev/openrs2/deob/util/map/Method.kt b/deob-util/src/main/java/dev/openrs2/deob/util/map/Method.kt index a0d023e679..3364c832be 100644 --- a/deob-util/src/main/java/dev/openrs2/deob/util/map/Method.kt +++ b/deob-util/src/main/java/dev/openrs2/deob/util/map/Method.kt @@ -2,7 +2,7 @@ package dev.openrs2.deob.util.map import java.util.SortedMap -data class Method( +public data class Method( val owner: String, val name: String, /* diff --git a/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMap.kt b/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMap.kt index eb8d2f3dcc..6e6a81284e 100644 --- a/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMap.kt +++ b/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMap.kt @@ -5,24 +5,24 @@ import dev.openrs2.util.collect.DisjointSet import java.util.SortedMap import java.util.TreeMap -data class NameMap( +public data class NameMap( val classes: SortedMap, val fields: SortedMap, val methods: SortedMap ) { - constructor() : this(TreeMap(), TreeMap(), TreeMap()) + public constructor() : this(TreeMap(), TreeMap(), TreeMap()) - fun add(other: NameMap) { + public fun add(other: NameMap) { classes.putAll(other.classes) fields.putAll(other.fields) methods.putAll(other.methods) } - fun mapClassName(name: String, default: String): String { + public fun mapClassName(name: String, default: String): String { return classes.getOrDefault(name, default) } - fun mapFieldName(partition: DisjointSet.Partition, default: String): String { + public fun mapFieldName(partition: DisjointSet.Partition, default: String): String { for (member in partition) { val field = fields[member] if (field != null) { @@ -33,7 +33,7 @@ data class NameMap( return default } - fun mapFieldOwner(partition: DisjointSet.Partition, default: String): String { + public fun mapFieldOwner(partition: DisjointSet.Partition, default: String): String { for (member in partition) { val field = fields[member] if (field != null) { @@ -44,7 +44,7 @@ data class NameMap( return default } - fun mapMethodName(partition: DisjointSet.Partition, default: String): String { + public fun mapMethodName(partition: DisjointSet.Partition, default: String): String { for (member in partition) { val method = methods[member] if (method != null) { @@ -55,7 +55,7 @@ data class NameMap( return default } - fun mapMethodOwner(partition: DisjointSet.Partition, default: String): String { + public fun mapMethodOwner(partition: DisjointSet.Partition, default: String): String { for (member in partition) { val method = methods[member] if (method != null) { diff --git a/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMapProvider.kt b/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMapProvider.kt index 0b9d838bb5..c1937049b3 100644 --- a/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMapProvider.kt +++ b/deob-util/src/main/java/dev/openrs2/deob/util/map/NameMapProvider.kt @@ -7,7 +7,7 @@ import java.nio.file.Paths import javax.inject.Inject import javax.inject.Provider -class NameMapProvider @Inject constructor(private val mapper: ObjectMapper) : Provider { +public class NameMapProvider @Inject constructor(private val mapper: ObjectMapper) : Provider { override fun get(): NameMap { val combinedMap = NameMap() diff --git a/deob/src/main/java/dev/openrs2/deob/ArgPartition.kt b/deob/src/main/java/dev/openrs2/deob/ArgPartition.kt index e48119df10..7baee802e0 100644 --- a/deob/src/main/java/dev/openrs2/deob/ArgPartition.kt +++ b/deob/src/main/java/dev/openrs2/deob/ArgPartition.kt @@ -3,4 +3,4 @@ package dev.openrs2.deob import dev.openrs2.asm.MemberRef import dev.openrs2.util.collect.DisjointSet -data class ArgPartition(val method: DisjointSet.Partition, val index: Int) +public data class ArgPartition(val method: DisjointSet.Partition, val index: Int) diff --git a/deob/src/main/java/dev/openrs2/deob/ArgRef.kt b/deob/src/main/java/dev/openrs2/deob/ArgRef.kt index 555d5ee702..8bfc11bd38 100644 --- a/deob/src/main/java/dev/openrs2/deob/ArgRef.kt +++ b/deob/src/main/java/dev/openrs2/deob/ArgRef.kt @@ -2,4 +2,4 @@ package dev.openrs2.deob import dev.openrs2.asm.MemberRef -data class ArgRef(val method: MemberRef, val index: Int) +public data class ArgRef(val method: MemberRef, val index: Int) diff --git a/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt b/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt index ccae4f3c83..a85f51d787 100644 --- a/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt +++ b/deob/src/main/java/dev/openrs2/deob/DeobfuscateCommand.kt @@ -4,9 +4,9 @@ import com.github.ajalt.clikt.core.CliktCommand import com.google.inject.Guice import java.nio.file.Paths -fun main(args: Array) = DeobfuscateCommand().main(args) +public fun main(args: Array): Unit = DeobfuscateCommand().main(args) -class DeobfuscateCommand : CliktCommand(name = "deob") { +public class DeobfuscateCommand : CliktCommand(name = "deob") { override fun run() { val injector = Guice.createInjector(DeobfuscatorModule) val deobfuscator = injector.getInstance(Deobfuscator::class.java) diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt index 0d5c547fd0..813cf739c7 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt @@ -15,10 +15,10 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class Deobfuscator @Inject constructor( +public class Deobfuscator @Inject constructor( @DeobfuscatorQualifier private val transformers: Set<@JvmSuppressWildcards Transformer> ) { - fun run(input: Path, output: Path) { + public fun run(input: Path, output: Path) { // read input jars/packs logger.info { "Reading input jars" } val client = Library.read("client", input.resolve("runescape_gl.pack200"), Pack200LibraryReader) diff --git a/deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt index 247fde060e..bfae314d4e 100644 --- a/deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt +++ b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorModule.kt @@ -37,7 +37,7 @@ import dev.openrs2.deob.transform.UnusedMethodTransformer import dev.openrs2.deob.transform.VisibilityTransformer import dev.openrs2.deob.util.DeobfuscatorUtilModule -object DeobfuscatorModule : AbstractModule() { +public object DeobfuscatorModule : AbstractModule() { override fun configure() { install(BundlerModule) install(DeobfuscatorUtilModule) diff --git a/deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt index 3823cfe2ec..098d1cfc77 100644 --- a/deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt +++ b/deob/src/main/java/dev/openrs2/deob/DeobfuscatorQualifier.kt @@ -5,4 +5,4 @@ import javax.inject.Qualifier @Qualifier @Retention(AnnotationRetention.RUNTIME) @Target(AnnotationTarget.FIELD, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION) -annotation class DeobfuscatorQualifier +public annotation class DeobfuscatorQualifier diff --git a/deob/src/main/java/dev/openrs2/deob/OriginalPcTable.kt b/deob/src/main/java/dev/openrs2/deob/OriginalPcTable.kt index fe8abfed6a..b8325849b9 100644 --- a/deob/src/main/java/dev/openrs2/deob/OriginalPcTable.kt +++ b/deob/src/main/java/dev/openrs2/deob/OriginalPcTable.kt @@ -6,7 +6,7 @@ import org.objectweb.asm.ClassWriter import org.objectweb.asm.Label import org.objectweb.asm.tree.LabelNode -class OriginalPcTable( +public class OriginalPcTable( private val pcs: Map, private val names: Map ) : Attribute("OriginalPcTable") { diff --git a/deob/src/main/java/dev/openrs2/deob/Profile.kt b/deob/src/main/java/dev/openrs2/deob/Profile.kt index c0946f67b8..aedb8269c2 100644 --- a/deob/src/main/java/dev/openrs2/deob/Profile.kt +++ b/deob/src/main/java/dev/openrs2/deob/Profile.kt @@ -3,11 +3,11 @@ package dev.openrs2.deob import dev.openrs2.asm.filter.GlobClassFilter import dev.openrs2.asm.filter.GlobMemberFilter -class Profile( - val excludedClasses: GlobClassFilter, - val excludedMethods: GlobMemberFilter, - val excludedFields: GlobMemberFilter, - val entryPoints: GlobMemberFilter, - val scrambledLibraries: Set, - val maxObfuscatedNameLen: Int +public class Profile( + public val excludedClasses: GlobClassFilter, + public val excludedMethods: GlobMemberFilter, + public val excludedFields: GlobMemberFilter, + public val entryPoints: GlobMemberFilter, + public val scrambledLibraries: Set, + public val maxObfuscatedNameLen: Int ) diff --git a/deob/src/main/java/dev/openrs2/deob/ProfileProvider.kt b/deob/src/main/java/dev/openrs2/deob/ProfileProvider.kt index 52b116b271..4d0dd3c311 100644 --- a/deob/src/main/java/dev/openrs2/deob/ProfileProvider.kt +++ b/deob/src/main/java/dev/openrs2/deob/ProfileProvider.kt @@ -6,14 +6,14 @@ import java.nio.file.Paths import javax.inject.Inject import javax.inject.Provider -class ProfileProvider @Inject constructor(private val mapper: ObjectMapper) : Provider { +public class ProfileProvider @Inject constructor(private val mapper: ObjectMapper) : Provider { override fun get(): Profile { return Files.newBufferedReader(PATH).use { reader -> mapper.readValue(reader, Profile::class.java) } } - companion object { + private companion object { private val PATH = Paths.get("share/deob/profile.yaml") } } diff --git a/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt b/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt index c1f1f8e41b..fca1e573b6 100644 --- a/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt +++ b/deob/src/main/java/dev/openrs2/deob/SignedClassUtils.kt @@ -7,12 +7,12 @@ import org.objectweb.asm.Type import org.objectweb.asm.tree.LdcInsnNode import org.objectweb.asm.tree.MethodNode -object SignedClassUtils { +public object SignedClassUtils { private val logger = InlineLogger() private val LOAD_SIGNED_CLASS_MATCHER = InsnMatcher.compile("LDC INVOKESTATIC ASTORE ALOAD GETFIELD ALOAD INVOKEVIRTUAL ALOAD INVOKEVIRTUAL POP") - fun move(loader: Library, client: Library, signLink: Library) { + public fun move(loader: Library, client: Library, signLink: Library) { // find signed classes val signedClasses = findSignedClasses(loader) logger.info { "Identified signed classes $signedClasses" } 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 03ba92e4af..b85f553827 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceInterpreter.kt @@ -7,7 +7,7 @@ import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.analysis.BasicInterpreter import org.objectweb.asm.tree.analysis.Interpreter -class ConstSourceInterpreter : Interpreter(Opcodes.ASM8) { +public class ConstSourceInterpreter : Interpreter(Opcodes.ASM8) { private val basicInterpreter = BasicInterpreter() override fun newValue(type: Type?): ConstSourceValue? { diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceValue.kt b/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceValue.kt index 19ececfa9c..12729571fa 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceValue.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/ConstSourceValue.kt @@ -4,12 +4,12 @@ import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.analysis.BasicValue import org.objectweb.asm.tree.analysis.Value -sealed class ConstSourceValue : Value { - data class Unknown(override val basicValue: BasicValue) : ConstSourceValue() - data class Insn(override val basicValue: BasicValue, val source: AbstractInsnNode) : ConstSourceValue() - data class Arg(override val basicValue: BasicValue) : ConstSourceValue() +public sealed class ConstSourceValue : Value { + public data class Unknown(override val basicValue: BasicValue) : ConstSourceValue() + public data class Insn(override val basicValue: BasicValue, val source: AbstractInsnNode) : ConstSourceValue() + public data class Arg(override val basicValue: BasicValue) : ConstSourceValue() - abstract val basicValue: BasicValue + public abstract val basicValue: BasicValue override fun getSize(): Int { return basicValue.size diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/ControlFlowAnalyzer.kt b/deob/src/main/java/dev/openrs2/deob/analysis/ControlFlowAnalyzer.kt index 5394113e7b..f37bdbd06b 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/ControlFlowAnalyzer.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/ControlFlowAnalyzer.kt @@ -9,7 +9,7 @@ import org.objectweb.asm.tree.analysis.Analyzer import org.objectweb.asm.tree.analysis.BasicInterpreter import org.objectweb.asm.tree.analysis.BasicValue -class ControlFlowAnalyzer : Analyzer(BasicInterpreter()) { +public class ControlFlowAnalyzer : Analyzer(BasicInterpreter()) { private val graph = DefaultDirectedGraph(DefaultEdge::class.java) override fun newControlFlowEdge(insnIndex: Int, successorIndex: Int) { @@ -23,7 +23,7 @@ class ControlFlowAnalyzer : Analyzer(BasicInterpreter()) { return true } - fun createGraph(owner: String, method: MethodNode): Graph { + public fun createGraph(owner: String, method: MethodNode): Graph { analyze(owner, method) return AsUnmodifiableGraph(graph) } diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/CopyAssignment.kt b/deob/src/main/java/dev/openrs2/deob/analysis/CopyAssignment.kt index 224ab7e613..eba7717843 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/CopyAssignment.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/CopyAssignment.kt @@ -1,3 +1,3 @@ package dev.openrs2.deob.analysis -data class CopyAssignment(val destination: Int, val source: Int) +public data class CopyAssignment(val destination: Int, val source: Int) diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/CopyPropagationAnalyzer.kt b/deob/src/main/java/dev/openrs2/deob/analysis/CopyPropagationAnalyzer.kt index 8c871084e5..9e90a37a55 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/CopyPropagationAnalyzer.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/CopyPropagationAnalyzer.kt @@ -7,7 +7,7 @@ import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode import java.util.Collections -class CopyPropagationAnalyzer(owner: String, method: MethodNode) : +public class CopyPropagationAnalyzer(owner: String, method: MethodNode) : DataFlowAnalyzer>(owner, method) { private val allAssignments = mutableSetOf() diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/DataFlowAnalyzer.kt b/deob/src/main/java/dev/openrs2/deob/analysis/DataFlowAnalyzer.kt index 848be59a82..7f6f1c39e0 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/DataFlowAnalyzer.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/DataFlowAnalyzer.kt @@ -7,7 +7,7 @@ import org.jgrapht.graph.EdgeReversedGraph import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.MethodNode -abstract class DataFlowAnalyzer(owner: String, private val method: MethodNode, backwards: Boolean = false) { +public abstract class DataFlowAnalyzer(owner: String, private val method: MethodNode, backwards: Boolean = false) { private val graph: Graph private val inSets = mutableMapOf() private val outSets = mutableMapOf() @@ -26,23 +26,23 @@ abstract class DataFlowAnalyzer(owner: String, private val method: MethodNode protected abstract fun join(set1: T, set2: T): T protected abstract fun transfer(set: T, insn: AbstractInsnNode): T - fun getInSet(insn: AbstractInsnNode): T? { + public fun getInSet(insn: AbstractInsnNode): T? { return getInSet(method.instructions.indexOf(insn)) } - fun getInSet(index: Int): T? { + public fun getInSet(index: Int): T? { return inSets[index] } - fun getOutSet(insn: AbstractInsnNode): T? { + public fun getOutSet(insn: AbstractInsnNode): T? { return getOutSet(method.instructions.indexOf(insn)) } - fun getOutSet(index: Int): T? { + public fun getOutSet(index: Int): T? { return outSets[index] } - fun analyze() { + public fun analyze() { val entrySet = createEntrySet() val initialSet = createInitialSet() diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteAnalyzer.kt b/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteAnalyzer.kt index 6bf41faea4..e2f1f1d1c1 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteAnalyzer.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteAnalyzer.kt @@ -9,7 +9,7 @@ import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.analysis.Frame -class FieldWriteAnalyzer( +public class FieldWriteAnalyzer( private val clazz: ClassNode, private val method: MethodNode, private val classPath: ClassPath, diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteCount.kt b/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteCount.kt index a74851a0c5..748c09366e 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteCount.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/FieldWriteCount.kt @@ -1,6 +1,6 @@ package dev.openrs2.deob.analysis -enum class FieldWriteCount { +public enum class FieldWriteCount { NEVER, EXACTLY_ONCE, ONCE_OR_MORE diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntBranch.kt b/deob/src/main/java/dev/openrs2/deob/analysis/IntBranch.kt index 937dc8abe4..641eb41e60 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntBranch.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntBranch.kt @@ -13,8 +13,8 @@ import org.objectweb.asm.Opcodes.IF_ICMPLE import org.objectweb.asm.Opcodes.IF_ICMPLT import org.objectweb.asm.Opcodes.IF_ICMPNE -object IntBranch { - fun evaluateUnary(opcode: Int, values: Set): IntBranchResult { +public object IntBranch { + public fun evaluateUnary(opcode: Int, values: Set): IntBranchResult { require(values.isNotEmpty()) var taken = 0 @@ -43,7 +43,7 @@ object IntBranch { } } - fun evaluateBinary(opcode: Int, values1: Set, values2: Set): IntBranchResult { + public fun evaluateBinary(opcode: Int, values1: Set, values2: Set): IntBranchResult { require(values1.isNotEmpty()) require(values2.isNotEmpty()) diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntBranchResult.kt b/deob/src/main/java/dev/openrs2/deob/analysis/IntBranchResult.kt index e6513151d6..b8090ab529 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntBranchResult.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntBranchResult.kt @@ -1,10 +1,10 @@ package dev.openrs2.deob.analysis -enum class IntBranchResult { +public enum class IntBranchResult { ALWAYS_TAKEN, NEVER_TAKEN, UNKNOWN; - companion object { - fun fromTakenNotTaken(taken: Int, notTaken: Int): IntBranchResult { + public companion object { + public fun fromTakenNotTaken(taken: Int, notTaken: Int): IntBranchResult { require(taken != 0 || notTaken != 0) return when { 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 02d132adc9..fcd5881fcc 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt @@ -8,7 +8,7 @@ import org.objectweb.asm.tree.IincInsnNode import org.objectweb.asm.tree.analysis.BasicInterpreter import org.objectweb.asm.tree.analysis.Interpreter -class IntInterpreter(private val args: Array) : Interpreter(Opcodes.ASM8) { +public class IntInterpreter(private val args: Array) : Interpreter(Opcodes.ASM8) { private val basicInterpreter = BasicInterpreter() override fun newValue(type: Type?): IntValue? { diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.kt b/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.kt index 8f022ed3a0..ec165e1955 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntValue.kt @@ -3,7 +3,7 @@ package dev.openrs2.deob.analysis import org.objectweb.asm.tree.analysis.BasicValue import org.objectweb.asm.tree.analysis.Value -data class IntValue(val basicValue: BasicValue, val set: IntValueSet = IntValueSet.Unknown) : Value { +public data class IntValue(val basicValue: BasicValue, val set: IntValueSet = IntValueSet.Unknown) : Value { override fun getSize(): Int { return basicValue.size } diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/IntValueSet.kt b/deob/src/main/java/dev/openrs2/deob/analysis/IntValueSet.kt index a7a0b6a84d..0942ccf1f5 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntValueSet.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntValueSet.kt @@ -1,7 +1,7 @@ package dev.openrs2.deob.analysis -sealed class IntValueSet { - data class Constant(val values: Set) : IntValueSet() { +public sealed class IntValueSet { + public data class Constant(val values: Set) : IntValueSet() { init { require(values.isNotEmpty()) } @@ -22,7 +22,7 @@ sealed class IntValueSet { } } - object Unknown : IntValueSet() { + public object Unknown : IntValueSet() { override val singleton: Int? get() = null @@ -31,11 +31,11 @@ sealed class IntValueSet { } } - abstract val singleton: Int? - abstract infix fun union(other: IntValueSet): IntValueSet + public abstract val singleton: Int? + public abstract infix fun union(other: IntValueSet): IntValueSet - companion object { - fun singleton(value: Int): IntValueSet { + public companion object { + public fun singleton(value: Int): IntValueSet { return Constant(setOf(value)) } } diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/LiveVariableAnalyzer.kt b/deob/src/main/java/dev/openrs2/deob/analysis/LiveVariableAnalyzer.kt index e91841402d..1c8c6dd55f 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/LiveVariableAnalyzer.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/LiveVariableAnalyzer.kt @@ -9,7 +9,7 @@ import org.objectweb.asm.tree.IincInsnNode import org.objectweb.asm.tree.MethodNode import org.objectweb.asm.tree.VarInsnNode -class LiveVariableAnalyzer(owner: String, method: MethodNode) : +public class LiveVariableAnalyzer(owner: String, method: MethodNode) : DataFlowAnalyzer(owner, method, backwards = true) { override fun createInitialSet(): IntSet { diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/ThisInterpreter.kt b/deob/src/main/java/dev/openrs2/deob/analysis/ThisInterpreter.kt index 08aed8261f..a5a19dfa8f 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/ThisInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/ThisInterpreter.kt @@ -6,7 +6,7 @@ import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.analysis.BasicInterpreter import org.objectweb.asm.tree.analysis.Interpreter -class ThisInterpreter : Interpreter(Opcodes.ASM8) { +public class ThisInterpreter : Interpreter(Opcodes.ASM8) { private val basicInterpreter = BasicInterpreter() override fun newValue(type: Type?): ThisValue? { diff --git a/deob/src/main/java/dev/openrs2/deob/analysis/ThisValue.kt b/deob/src/main/java/dev/openrs2/deob/analysis/ThisValue.kt index 79b7e3af61..a5748fb33a 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/ThisValue.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/ThisValue.kt @@ -3,7 +3,7 @@ package dev.openrs2.deob.analysis import org.objectweb.asm.tree.analysis.BasicValue import org.objectweb.asm.tree.analysis.Value -data class ThisValue(val basicValue: BasicValue, val isThis: Boolean) : Value { +public data class ThisValue(val basicValue: BasicValue, val isThis: Boolean) : Value { override fun getSize(): Int { return basicValue.size } diff --git a/deob/src/main/java/dev/openrs2/deob/filter/BrowserControlFilter.kt b/deob/src/main/java/dev/openrs2/deob/filter/BrowserControlFilter.kt index 90349a03da..0aeb295aa9 100644 --- a/deob/src/main/java/dev/openrs2/deob/filter/BrowserControlFilter.kt +++ b/deob/src/main/java/dev/openrs2/deob/filter/BrowserControlFilter.kt @@ -8,15 +8,15 @@ import dev.openrs2.asm.hasCode import org.objectweb.asm.tree.ClassNode import org.objectweb.asm.tree.MethodInsnNode -class BrowserControlFilter private constructor(private val clazz: String) : MemberFilter { +public class BrowserControlFilter private constructor(private val clazz: String) : MemberFilter { override fun matches(owner: String, name: String, desc: String): Boolean { return clazz == owner } - companion object { + public companion object { private val logger = InlineLogger() - fun create(classPath: ClassPath): MemberFilter { + public fun create(classPath: ClassPath): MemberFilter { val browserControlClass = findBrowserControlClass(classPath) return if (browserControlClass != null) { diff --git a/deob/src/main/java/dev/openrs2/deob/filter/ReflectedConstructorFilter.kt b/deob/src/main/java/dev/openrs2/deob/filter/ReflectedConstructorFilter.kt index f4f2ca476d..3c488796d9 100644 --- a/deob/src/main/java/dev/openrs2/deob/filter/ReflectedConstructorFilter.kt +++ b/deob/src/main/java/dev/openrs2/deob/filter/ReflectedConstructorFilter.kt @@ -7,15 +7,15 @@ import dev.openrs2.asm.filter.MemberFilter import dev.openrs2.asm.hasCode import org.objectweb.asm.tree.MethodNode -class ReflectedConstructorFilter private constructor(private val classes: Set) : MemberFilter { +public class ReflectedConstructorFilter private constructor(private val classes: Set) : MemberFilter { override fun matches(owner: String, name: String, desc: String): Boolean { return classes.contains(owner) && name == "" } - companion object { + public companion object { private val logger = InlineLogger() - fun create(classPath: ClassPath): MemberFilter { + public fun create(classPath: ClassPath): MemberFilter { val classes = mutableSetOf() for (library in classPath.libraries) { diff --git a/deob/src/main/java/dev/openrs2/deob/remap/ArgumentMappingGenerator.kt b/deob/src/main/java/dev/openrs2/deob/remap/ArgumentMappingGenerator.kt index 25465b5890..238e7a8be4 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/ArgumentMappingGenerator.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/ArgumentMappingGenerator.kt @@ -3,10 +3,10 @@ package dev.openrs2.deob.remap import dev.openrs2.deob.ArgRef import dev.openrs2.deob.util.map.NameMap -class ArgumentMappingGenerator( +public class ArgumentMappingGenerator( private val nameMap: NameMap ) { - fun generate(): Map { + public fun generate(): Map { val argumentNames = mutableMapOf() for ((methodRef, method) in nameMap.methods) { diff --git a/deob/src/main/java/dev/openrs2/deob/remap/ClassMappingGenerator.kt b/deob/src/main/java/dev/openrs2/deob/remap/ClassMappingGenerator.kt index f6c17cd481..2c814e9410 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/ClassMappingGenerator.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/ClassMappingGenerator.kt @@ -6,7 +6,7 @@ import dev.openrs2.asm.filter.ClassFilter import dev.openrs2.deob.util.map.NameMap import org.objectweb.asm.Opcodes -class ClassMappingGenerator( +public class ClassMappingGenerator( private val classPath: ClassPath, private val excludedClasses: ClassFilter, private val nameMap: NameMap @@ -14,7 +14,7 @@ class ClassMappingGenerator( private val nameGenerator = NameGenerator() private val mapping = mutableMapOf() - fun generate(): Map { + public fun generate(): Map { for (clazz in classPath.libraryClasses) { populateMapping(clazz) } diff --git a/deob/src/main/java/dev/openrs2/deob/remap/ClassNamePrefix.kt b/deob/src/main/java/dev/openrs2/deob/remap/ClassNamePrefix.kt index 0cd1987682..e37577c20a 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/ClassNamePrefix.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/ClassNamePrefix.kt @@ -5,20 +5,20 @@ import dev.openrs2.asm.classpath.Library private val BOUNDARY_CHARS = charArrayOf('/', '!') -fun String.splitAtLibraryBoundary(): Pair { +public fun String.splitAtLibraryBoundary(): Pair { val index = indexOf('!') return Pair(substring(0, index), substring(index + 1)) } -fun String.getLibraryAndPackageName(): String { +public fun String.getLibraryAndPackageName(): String { return substring(0, lastIndexOfAny(BOUNDARY_CHARS) + 1) } -fun String.getClassName(): String { +public fun String.getClassName(): String { return substring(lastIndexOfAny(BOUNDARY_CHARS) + 1) } -class ClassNamePrefixRemapper(vararg libraries: Library) : ExtendedRemapper() { +public class ClassNamePrefixRemapper(vararg libraries: Library) : ExtendedRemapper() { private val mapping = mutableMapOf() init { @@ -37,7 +37,7 @@ class ClassNamePrefixRemapper(vararg libraries: Library) : ExtendedRemapper() { } } -object StripClassNamePrefixRemapper : ExtendedRemapper() { +public object StripClassNamePrefixRemapper : ExtendedRemapper() { override fun map(internalName: String): String { return internalName.substring(internalName.indexOf('!') + 1) } diff --git a/deob/src/main/java/dev/openrs2/deob/remap/FieldMappingGenerator.kt b/deob/src/main/java/dev/openrs2/deob/remap/FieldMappingGenerator.kt index bb10eb5580..110aaa50a5 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/FieldMappingGenerator.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/FieldMappingGenerator.kt @@ -8,7 +8,7 @@ import dev.openrs2.util.collect.DisjointSet import dev.openrs2.util.indefiniteArticle import org.objectweb.asm.Type -class FieldMappingGenerator( +public class FieldMappingGenerator( private val classPath: ClassPath, private val excludedFields: MemberFilter, private val nameMap: NameMap, @@ -17,7 +17,7 @@ class FieldMappingGenerator( ) { private val nameGenerator = NameGenerator() - fun generate(): Map, String> { + public fun generate(): Map, String> { val mapping = mutableMapOf, String>() for (partition in inheritedFieldSets) { diff --git a/deob/src/main/java/dev/openrs2/deob/remap/MethodMappingGenerator.kt b/deob/src/main/java/dev/openrs2/deob/remap/MethodMappingGenerator.kt index 9adc882ac6..f976fa1f9b 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/MethodMappingGenerator.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/MethodMappingGenerator.kt @@ -8,7 +8,7 @@ import dev.openrs2.deob.util.map.NameMap import dev.openrs2.util.collect.DisjointSet import org.objectweb.asm.Opcodes -class MethodMappingGenerator( +public class MethodMappingGenerator( private val classPath: ClassPath, private val excludedMethods: MemberFilter, private val nameMap: NameMap, @@ -16,7 +16,7 @@ class MethodMappingGenerator( ) { private var index = 0 - fun generate(): Map, String> { + public fun generate(): Map, String> { val mapping = mutableMapOf, String>() for (partition in inheritedMethodSets) { @@ -32,9 +32,9 @@ class MethodMappingGenerator( return mapping } - companion object { + public companion object { @Deprecated("No replacement yet") - fun isRenamable( + public fun isRenamable( classPath: ClassPath, excludedMethods: MemberFilter, partition: DisjointSet.Partition diff --git a/deob/src/main/java/dev/openrs2/deob/remap/NameGenerator.kt b/deob/src/main/java/dev/openrs2/deob/remap/NameGenerator.kt index dfb04f5756..22e3d0fb5a 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/NameGenerator.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/NameGenerator.kt @@ -1,9 +1,9 @@ package dev.openrs2.deob.remap -class NameGenerator { +public class NameGenerator { private val prefixes = mutableMapOf() - fun generate(prefix: String): String { + public fun generate(prefix: String): String { require(prefix.isNotEmpty()) val separator = if (prefix.last().isDigit()) { diff --git a/deob/src/main/java/dev/openrs2/deob/remap/StaticClassGenerator.kt b/deob/src/main/java/dev/openrs2/deob/remap/StaticClassGenerator.kt index 18243f124e..daa9d8f30b 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/StaticClassGenerator.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/StaticClassGenerator.kt @@ -1,10 +1,10 @@ package dev.openrs2.deob.remap -class StaticClassGenerator(private val generator: NameGenerator, private val maxMembers: Int) { +public class StaticClassGenerator(private val generator: NameGenerator, private val maxMembers: Int) { private var lastClass: String? = null private var members = 0 - fun generate(): String { + public fun generate(): String { var clazz = lastClass if (clazz == null || members >= maxMembers) { diff --git a/deob/src/main/java/dev/openrs2/deob/remap/StaticField.kt b/deob/src/main/java/dev/openrs2/deob/remap/StaticField.kt index ccc2b20600..b90515abc0 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/StaticField.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/StaticField.kt @@ -2,4 +2,4 @@ package dev.openrs2.deob.remap import org.objectweb.asm.tree.AbstractInsnNode -class StaticField(val owner: String, val initializer: List?) +public class StaticField(public val owner: String, public val initializer: List?) diff --git a/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt b/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt index 6936670e81..312064c3b9 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/StaticFieldUnscrambler.kt @@ -13,7 +13,7 @@ import org.objectweb.asm.tree.AbstractInsnNode import org.objectweb.asm.tree.FieldInsnNode import org.objectweb.asm.tree.MethodNode -class StaticFieldUnscrambler( +public class StaticFieldUnscrambler( private val classPath: ClassPath, private val excludedFields: MemberFilter, private val scrambledLibraries: Set, @@ -23,7 +23,7 @@ class StaticFieldUnscrambler( ) { private val generator = StaticClassGenerator(staticClassNameGenerator, MAX_FIELDS_PER_CLASS) - fun unscramble(): Map, StaticField> { + public fun unscramble(): Map, StaticField> { val fields = mutableMapOf, StaticField>() for (library in classPath.libraries) { diff --git a/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt b/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt index 9d0aea461b..d6c1ca55ac 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/StaticMethodUnscrambler.kt @@ -7,7 +7,7 @@ import dev.openrs2.deob.util.map.NameMap import dev.openrs2.util.collect.DisjointSet import org.objectweb.asm.Opcodes -class StaticMethodUnscrambler( +public class StaticMethodUnscrambler( private val classPath: ClassPath, private val excludedMethods: MemberFilter, private val scrambledLibraries: Set, @@ -17,7 +17,7 @@ class StaticMethodUnscrambler( ) { private val generator = StaticClassGenerator(staticClassNameGenerator, MAX_METHODS_PER_CLASS) - fun unscramble(): Map, String> { + public fun unscramble(): Map, String> { val owners = mutableMapOf, String>() for (library in classPath.libraries) { diff --git a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt index ffde8315a0..4978e56dfa 100644 --- a/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt +++ b/deob/src/main/java/dev/openrs2/deob/remap/TypedRemapper.kt @@ -12,7 +12,7 @@ import dev.openrs2.deob.util.map.NameMap import dev.openrs2.util.collect.DisjointSet import org.objectweb.asm.tree.AbstractInsnNode -class TypedRemapper private constructor( +public class TypedRemapper private constructor( private val inheritedFieldSets: DisjointSet, private val inheritedMethodSets: DisjointSet, private val classes: Map, @@ -67,10 +67,10 @@ class TypedRemapper private constructor( return argumentNames[argument] ?: argumentName } - companion object { + public companion object { private val logger = InlineLogger() - fun create(classPath: ClassPath, profile: Profile, nameMap: NameMap): TypedRemapper { + public fun create(classPath: ClassPath, profile: Profile, nameMap: NameMap): TypedRemapper { val inheritedFieldSets = classPath.createInheritedFieldSets() val inheritedMethodSets = classPath.createInheritedMethodSets() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt index 79f895cf19..14a6ca7adf 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt @@ -13,7 +13,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class BitShiftTransformer : Transformer() { +public class BitShiftTransformer : Transformer() { private var simplified = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt index 14d7fe9be4..69c4b5ac5b 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt @@ -16,7 +16,7 @@ import org.objectweb.asm.tree.VarInsnNode import javax.inject.Singleton @Singleton -class BitwiseOpTransformer : Transformer() { +public class BitwiseOpTransformer : Transformer() { private val methodOps = mutableMapOf() private var inlinedOps = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt index 91eee615df..ab5829ad36 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt @@ -8,7 +8,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class BundlerTransformer @Inject constructor( +public class BundlerTransformer @Inject constructor( @BundlerQualifier private val transformers: Set<@JvmSuppressWildcards Transformer> ) : Transformer() { override fun transform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt index f9685f0598..ab6d0402f0 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/CanvasTransformer.kt @@ -8,7 +8,7 @@ import org.objectweb.asm.tree.ClassNode import javax.inject.Singleton @Singleton -class CanvasTransformer : Transformer() { +public class CanvasTransformer : Transformer() { override fun transformClass( classPath: ClassPath, library: Library, diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt index bf60564ada..d11c9f7f38 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt @@ -18,7 +18,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class ClassLiteralTransformer : Transformer() { +public class ClassLiteralTransformer : Transformer() { private val classForNameMethods = mutableListOf() private var classLiterals = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt index 468328388c..a6ed2705a2 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt @@ -51,7 +51,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class ConstantArgTransformer @Inject constructor(private val profile: Profile) : Transformer() { +public class ConstantArgTransformer @Inject constructor(private val profile: Profile) : Transformer() { private val pendingMethods = LinkedHashSet() private val arglessMethods = mutableSetOf>() private val argValues = mutableMapOf() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CopyPropagationTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/CopyPropagationTransformer.kt index e02f09f5f7..73b82bcf0e 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CopyPropagationTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/CopyPropagationTransformer.kt @@ -38,7 +38,7 @@ import javax.inject.Singleton * ``` */ @Singleton -class CopyPropagationTransformer : Transformer() { +public class CopyPropagationTransformer : Transformer() { private var propagatedLocals = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt index cf0ca00e94..e5fac3f6d0 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt @@ -13,7 +13,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class CounterTransformer : Transformer() { +public class CounterTransformer : Transformer() { private val counters = mutableSetOf() override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt index 7543e8e742..de8e629e6d 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt @@ -13,7 +13,7 @@ import org.objectweb.asm.tree.TypeInsnNode import javax.inject.Singleton @Singleton -class EmptyClassTransformer : Transformer() { +public class EmptyClassTransformer : Transformer() { private var removedClasses = 0 private val emptyClasses = mutableSetOf() private val referencedClasses = mutableSetOf() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt index 97dff4a8bc..1c4691b411 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt @@ -29,7 +29,7 @@ import javax.inject.Singleton * remove these exception handlers too. */ @Singleton -class ExceptionTracingTransformer : Transformer() { +public class ExceptionTracingTransformer : Transformer() { private var tracingTryCatches = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt index 0dedac2340..6f075beb90 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FernflowerExceptionTransformer.kt @@ -12,7 +12,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class FernflowerExceptionTransformer : Transformer() { +public class FernflowerExceptionTransformer : Transformer() { private var nopsInserted = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt index 9a67087ef8..0c8b3e756c 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt @@ -11,7 +11,7 @@ import org.objectweb.asm.tree.FieldNode import javax.inject.Singleton @Singleton -class FieldOrderTransformer : Transformer() { +public class FieldOrderTransformer : Transformer() { override fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { sortFields(clazz, CONSTRUCTOR, Opcodes.PUTFIELD) sortFields(clazz, STATIC_CONSTRUCTOR, Opcodes.PUTSTATIC) diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt index 20b5249fd4..26360eeec8 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FinalFieldTransformer.kt @@ -20,7 +20,7 @@ import org.objectweb.asm.tree.analysis.Analyzer import javax.inject.Singleton @Singleton -class FinalFieldTransformer : Transformer() { +public class FinalFieldTransformer : Transformer() { private lateinit var inheritedFieldSets: DisjointSet private val nonFinalFields = mutableSetOf>() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt index 4c1efb72fe..c2a02b5a04 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt @@ -12,7 +12,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class FinalTransformer : Transformer() { +public class FinalTransformer : Transformer() { private val superClasses = mutableListOf() private lateinit var inheritedMethodSets: DisjointSet private var methodsChanged = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt index 7a020eedb7..a09621aa22 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt @@ -49,7 +49,7 @@ import javax.inject.Singleton * verifiable output. */ @Singleton -class InvokeSpecialTransformer : Transformer() { +public class InvokeSpecialTransformer : Transformer() { private var invokeSpecialsReplaced = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt index e16d62e4b4..e7a0ab93b5 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt @@ -9,7 +9,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class MethodOrderTransformer : Transformer() { +public class MethodOrderTransformer : Transformer() { override fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { clazz.methods.sortWith(STATIC_COMPARATOR.then(INIT_COMPARATOR)) return false diff --git a/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt index a88db6f942..2ffde83934 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt @@ -43,7 +43,7 @@ import javax.inject.Singleton * necessary for Fernflower compatibility. */ @Singleton -class MonitorTransformer : Transformer() { +public class MonitorTransformer : Transformer() { private var subroutinesInlined = 0 private var tryRangesExtended = 0 private var loadsReplaced = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt index 718a5a1041..df169a3bec 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt @@ -17,7 +17,7 @@ import org.objectweb.asm.tree.VarInsnNode import javax.inject.Singleton @Singleton -class OpaquePredicateTransformer : Transformer() { +public class OpaquePredicateTransformer : Transformer() { private val flowObstructors = mutableSetOf() private var opaquePredicates = 0 private var stores = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt index be62ddbbb7..73f9bd24e8 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt @@ -14,7 +14,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class OriginalNameTransformer : Transformer() { +public class OriginalNameTransformer : Transformer() { override fun transformClass(classPath: ClassPath, library: Library, clazz: ClassNode): Boolean { if (clazz.invisibleAnnotations == null) { clazz.invisibleAnnotations = mutableListOf() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt index aee515159d..b498c2fbfc 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt @@ -17,7 +17,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class OriginalPcRestoreTransformer @Inject constructor(private val nameMap: NameMap) : Transformer() { +public class OriginalPcRestoreTransformer @Inject constructor(private val nameMap: NameMap) : Transformer() { private var originalPcsRestored = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt index 3ca9d5742f..6eb644933e 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt @@ -9,7 +9,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class OriginalPcSaveTransformer : Transformer() { +public class OriginalPcSaveTransformer : Transformer() { override fun transformCode(classPath: ClassPath, library: Library, clazz: ClassNode, method: MethodNode): Boolean { for ((pc, insn) in method.instructions.filter { it.opcode != -1 }.withIndex()) { classPath.originalPcs[insn] = pc diff --git a/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt index a32b4be9ea..8760a5e7df 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt @@ -13,7 +13,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class OverrideTransformer : Transformer() { +public class OverrideTransformer : Transformer() { private var overrides = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt index 443215abc9..1960bd11fe 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/RedundantGotoTransformer.kt @@ -13,7 +13,7 @@ import org.objectweb.asm.tree.MethodNode import javax.inject.Singleton @Singleton -class RedundantGotoTransformer : Transformer() { +public class RedundantGotoTransformer : Transformer() { private var removed = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt index 4f3799ae4d..c599b42585 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/RemapTransformer.kt @@ -9,7 +9,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class RemapTransformer @Inject constructor( +public class RemapTransformer @Inject constructor( private val profile: Profile, private val nameMap: NameMap ) : Transformer() { 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 3e0459c194..8fbf8f340f 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt @@ -19,7 +19,7 @@ import org.objectweb.asm.tree.VarInsnNode import javax.inject.Singleton @Singleton -class ResetTransformer : Transformer() { +public class ResetTransformer : Transformer() { private val resetMethods = mutableSetOf() override fun preTransform(classPath: ClassPath) { 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 3a27dcae7e..62732dc5de 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt @@ -27,7 +27,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class UnusedArgTransformer @Inject constructor(private val profile: Profile) : Transformer() { +public class UnusedArgTransformer @Inject constructor(private val profile: Profile) : Transformer() { private val retainedArgs = mutableSetOf() private lateinit var inheritedMethodSets: DisjointSet private var deletedArgs = 0 diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt index 911cca56ae..5a8aefaa8a 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt @@ -15,7 +15,7 @@ import org.objectweb.asm.tree.VarInsnNode import javax.inject.Singleton @Singleton -class UnusedLocalTransformer : Transformer() { +public class UnusedLocalTransformer : Transformer() { private var localsRemoved = 0 override fun preTransform(classPath: ClassPath) { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt index 49362ae1c2..ca41ebecdc 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedMethodTransformer.kt @@ -21,7 +21,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class UnusedMethodTransformer @Inject constructor(private val profile: Profile) : Transformer() { +public class UnusedMethodTransformer @Inject constructor(private val profile: Profile) : Transformer() { private lateinit var inheritedMethodSets: DisjointSet private lateinit var excludedMethods: MemberFilter private val methodReferences = HashMultimap.create, MemberRef>() diff --git a/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt index 38d827f406..4bb93adc21 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt @@ -23,7 +23,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class VisibilityTransformer @Inject constructor(private val profile: Profile) : Transformer() { +public class VisibilityTransformer @Inject constructor(private val profile: Profile) : Transformer() { private lateinit var inheritedFieldSets: DisjointSet private lateinit var inheritedMethodSets: DisjointSet private lateinit var entryPoints: MemberFilter diff --git a/game/src/main/java/dev/openrs2/game/GameCommand.kt b/game/src/main/java/dev/openrs2/game/GameCommand.kt index 766dbc5773..0c1c465f67 100644 --- a/game/src/main/java/dev/openrs2/game/GameCommand.kt +++ b/game/src/main/java/dev/openrs2/game/GameCommand.kt @@ -3,9 +3,9 @@ package dev.openrs2.game import com.github.ajalt.clikt.core.CliktCommand import com.google.inject.Guice -fun main(args: Array) = GameCommand().main(args) +public fun main(args: Array): Unit = GameCommand().main(args) -class GameCommand : CliktCommand(name = "game") { +public class GameCommand : CliktCommand(name = "game") { override fun run() { val injector = Guice.createInjector(GameModule) val server = injector.getInstance(GameServer::class.java) diff --git a/game/src/main/java/dev/openrs2/game/GameModule.kt b/game/src/main/java/dev/openrs2/game/GameModule.kt index 1dac9697f2..f49375b693 100644 --- a/game/src/main/java/dev/openrs2/game/GameModule.kt +++ b/game/src/main/java/dev/openrs2/game/GameModule.kt @@ -2,7 +2,7 @@ package dev.openrs2.game import com.google.inject.AbstractModule -object GameModule : AbstractModule() { +public object GameModule : AbstractModule() { override fun configure() { // empty } diff --git a/game/src/main/java/dev/openrs2/game/GameServer.kt b/game/src/main/java/dev/openrs2/game/GameServer.kt index 9aedc99369..c61463535d 100644 --- a/game/src/main/java/dev/openrs2/game/GameServer.kt +++ b/game/src/main/java/dev/openrs2/game/GameServer.kt @@ -3,8 +3,8 @@ package dev.openrs2.game import javax.inject.Singleton @Singleton -class GameServer { - fun run() { +public class GameServer { + public fun run() { TODO() } } diff --git a/util/src/main/java/dev/openrs2/util/StringUtils.kt b/util/src/main/java/dev/openrs2/util/StringUtils.kt index d48ac8d4a5..60216e9ef7 100644 --- a/util/src/main/java/dev/openrs2/util/StringUtils.kt +++ b/util/src/main/java/dev/openrs2/util/StringUtils.kt @@ -2,7 +2,7 @@ package dev.openrs2.util import dev.openrs2.util.charset.Cp1252Charset -fun CharSequence.indefiniteArticle(): String { +public fun CharSequence.indefiniteArticle(): String { require(isNotEmpty()) return when (first().toLowerCase()) { @@ -11,7 +11,7 @@ fun CharSequence.indefiniteArticle(): String { } } -fun CharSequence.krHashCode(): Int { +public fun CharSequence.krHashCode(): Int { var hash = 0 for (c in this) { hash = ((hash shl 5) - hash) + Cp1252Charset.encode(c) diff --git a/util/src/main/java/dev/openrs2/util/charset/Cp1252Charset.kt b/util/src/main/java/dev/openrs2/util/charset/Cp1252Charset.kt index cf1c48798f..c8db2cc6f8 100644 --- a/util/src/main/java/dev/openrs2/util/charset/Cp1252Charset.kt +++ b/util/src/main/java/dev/openrs2/util/charset/Cp1252Charset.kt @@ -7,7 +7,7 @@ import java.nio.charset.CharsetDecoder import java.nio.charset.CharsetEncoder import java.nio.charset.CoderResult -object Cp1252Charset : Charset("Cp1252", null) { +public object Cp1252Charset : Charset("Cp1252", null) { private val CODE_PAGE = charArrayOf( '\u20AC', '\u0000', '\u201A', '\u0192', '\u201E', '\u2026', '\u2020', '\u2021', '\u02C6', '\u2030', '\u0160', '\u2039', '\u0152', '\u0000', '\u017D', '\u0000', @@ -34,7 +34,7 @@ object Cp1252Charset : Charset("Cp1252", null) { } } - fun decode(byte: Byte): Char { + public fun decode(byte: Byte): Char { val char = DECODE_TABLE[byte.toInt() and 0xFF] return if (char == '\u0000') { REPLACEMENT_CHAR @@ -43,7 +43,7 @@ object Cp1252Charset : Charset("Cp1252", null) { } } - fun encode(char: Char): Byte { + public fun encode(char: Char): Byte { val byte = ENCODE_TABLE[char.toInt()] return if (byte.toInt() == 0) { REPLACEMENT_BYTE diff --git a/util/src/main/java/dev/openrs2/util/charset/ModifiedUtf8Charset.kt b/util/src/main/java/dev/openrs2/util/charset/ModifiedUtf8Charset.kt index 44447810a2..ce9b54614a 100644 --- a/util/src/main/java/dev/openrs2/util/charset/ModifiedUtf8Charset.kt +++ b/util/src/main/java/dev/openrs2/util/charset/ModifiedUtf8Charset.kt @@ -7,7 +7,7 @@ import java.nio.charset.CharsetDecoder import java.nio.charset.CharsetEncoder import java.nio.charset.CoderResult -object ModifiedUtf8Charset : Charset("ModifiedUtf8", null) { +public object ModifiedUtf8Charset : Charset("ModifiedUtf8", null) { override fun contains(cs: Charset): Boolean { return Charsets.UTF_8.contains(cs) || cs is Cp1252Charset || cs is ModifiedUtf8Charset } diff --git a/util/src/main/java/dev/openrs2/util/collect/DisjointSet.kt b/util/src/main/java/dev/openrs2/util/collect/DisjointSet.kt index 484645be54..e3b86d006d 100644 --- a/util/src/main/java/dev/openrs2/util/collect/DisjointSet.kt +++ b/util/src/main/java/dev/openrs2/util/collect/DisjointSet.kt @@ -5,13 +5,13 @@ package dev.openrs2.util.collect * non-overlapping subsets. New elements belong to singleton subsets. The * [union] function combines two subsets together into a single larger subset. */ -interface DisjointSet : Iterable> { - interface Partition : Iterable +public interface DisjointSet : Iterable> { + public interface Partition : Iterable - val elements: Int - val partitions: Int + public val elements: Int + public val partitions: Int - fun add(x: T): Partition - operator fun get(x: T): Partition? - fun union(x: Partition, y: Partition) + public fun add(x: T): Partition + public operator fun get(x: T): Partition? + public fun union(x: Partition, y: Partition) } diff --git a/util/src/main/java/dev/openrs2/util/collect/ForestDisjointSet.kt b/util/src/main/java/dev/openrs2/util/collect/ForestDisjointSet.kt index c1d061d2a6..19eff687a4 100644 --- a/util/src/main/java/dev/openrs2/util/collect/ForestDisjointSet.kt +++ b/util/src/main/java/dev/openrs2/util/collect/ForestDisjointSet.kt @@ -7,7 +7,7 @@ import java.util.ArrayDeque * in chapter 21.3 of the third edition of CLRS. It uses path compression and * union by rank. */ -class ForestDisjointSet : DisjointSet { +public class ForestDisjointSet : DisjointSet { private class Node(val value: T) : DisjointSet.Partition { val children = mutableListOf>() private var _parent = this @@ -65,9 +65,9 @@ class ForestDisjointSet : DisjointSet { } private val nodes = mutableMapOf>() - override val elements + override val elements: Int get() = nodes.size - override var partitions = 0 + override var partitions: Int = 0 private set override fun add(x: T): DisjointSet.Partition { diff --git a/util/src/main/java/dev/openrs2/util/collect/IterableUtils.kt b/util/src/main/java/dev/openrs2/util/collect/IterableUtils.kt index 2146ed86d4..6ae07d55e2 100644 --- a/util/src/main/java/dev/openrs2/util/collect/IterableUtils.kt +++ b/util/src/main/java/dev/openrs2/util/collect/IterableUtils.kt @@ -1,10 +1,10 @@ package dev.openrs2.util.collect -fun MutableIterable.removeFirst(): T { +public fun MutableIterable.removeFirst(): T { return removeFirstOrNull() ?: throw NoSuchElementException() } -fun MutableIterable.removeFirstOrNull(): T? { +public fun MutableIterable.removeFirstOrNull(): T? { val iterator = iterator() if (!iterator.hasNext()) { return null @@ -16,7 +16,7 @@ fun MutableIterable.removeFirstOrNull(): T? { return element } -inline fun MutableIterable.removeFirst(predicate: (T) -> Boolean): Boolean { +public inline fun MutableIterable.removeFirst(predicate: (T) -> Boolean): Boolean { val iterator = iterator() for (element in iterator) { if (predicate(element)) { diff --git a/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt b/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt index ffd46e99ef..c5a5cbf078 100644 --- a/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt +++ b/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt @@ -7,9 +7,9 @@ import java.util.jar.Manifest import java.util.zip.Deflater import java.util.zip.ZipEntry -class DeterministicJarOutputStream : JarOutputStream { - constructor(out: OutputStream) : super(out) - constructor(out: OutputStream, man: Manifest) : super(out, man) +public class DeterministicJarOutputStream : JarOutputStream { + public constructor(out: OutputStream) : super(out) + public constructor(out: OutputStream, man: Manifest) : super(out, man) init { setLevel(Deflater.BEST_COMPRESSION) diff --git a/util/src/main/java/dev/openrs2/util/io/InputStreamExtensions.kt b/util/src/main/java/dev/openrs2/util/io/InputStreamExtensions.kt index 450c73b177..2fd5090142 100644 --- a/util/src/main/java/dev/openrs2/util/io/InputStreamExtensions.kt +++ b/util/src/main/java/dev/openrs2/util/io/InputStreamExtensions.kt @@ -3,7 +3,7 @@ package dev.openrs2.util.io import java.io.InputStream import java.util.Arrays -fun InputStream.contentEquals(other: InputStream): Boolean { +public fun InputStream.contentEquals(other: InputStream): Boolean { val buf1 = ByteArray(4096) val buf2 = ByteArray(4096) diff --git a/util/src/main/java/dev/openrs2/util/io/JarInputStreamExtensions.kt b/util/src/main/java/dev/openrs2/util/io/JarInputStreamExtensions.kt index afea6f9069..ade8bac750 100644 --- a/util/src/main/java/dev/openrs2/util/io/JarInputStreamExtensions.kt +++ b/util/src/main/java/dev/openrs2/util/io/JarInputStreamExtensions.kt @@ -1,6 +1,7 @@ package dev.openrs2.util.io +import java.util.jar.JarEntry import java.util.jar.JarInputStream -val JarInputStream.entries +public val JarInputStream.entries: Sequence get() = generateSequence { nextJarEntry } diff --git a/util/src/main/java/dev/openrs2/util/io/PathExtensions.kt b/util/src/main/java/dev/openrs2/util/io/PathExtensions.kt index d01ae5bb71..8dfd68ab46 100644 --- a/util/src/main/java/dev/openrs2/util/io/PathExtensions.kt +++ b/util/src/main/java/dev/openrs2/util/io/PathExtensions.kt @@ -14,7 +14,7 @@ import java.nio.file.StandardCopyOption import java.nio.file.StandardOpenOption import java.nio.file.attribute.FileAttribute -fun Path.fsync() { +public fun Path.fsync() { require(Files.isRegularFile(this) || Files.isDirectory(this)) FileChannel.open(this, StandardOpenOption.READ).use { channel -> @@ -22,7 +22,7 @@ fun Path.fsync() { } } -fun Path.recursiveCopy( +public fun Path.recursiveCopy( destination: Path, visitOptions: Array = emptyArray(), copyOptions: Array = emptyArray() @@ -38,7 +38,7 @@ fun Path.recursiveCopy( } } -fun Path.recursiveEquals( +public fun Path.recursiveEquals( other: Path, linkOptions: Array = emptyArray(), openOptions: Array = emptyArray() @@ -77,7 +77,7 @@ fun Path.recursiveEquals( return true } -inline fun useTempFile( +public inline fun useTempFile( prefix: String? = null, suffix: String? = null, vararg attributes: FileAttribute<*>, @@ -91,7 +91,7 @@ inline fun useTempFile( } } -inline fun Path.useTempFile( +public inline fun Path.useTempFile( prefix: String? = null, suffix: String? = null, vararg attributes: FileAttribute<*>, @@ -105,7 +105,7 @@ inline fun Path.useTempFile( } } -inline fun Path.atomicWrite(f: (Path) -> T): T { +public inline fun Path.atomicWrite(f: (Path) -> T): T { val tempFile = Files.createTempFile(parent, ".$fileName", ".tmp") try { val result = f(tempFile) @@ -116,7 +116,7 @@ inline fun Path.atomicWrite(f: (Path) -> T): T { } } -inline fun Path.useAtomicBufferedWriter(vararg options: OpenOption, f: (BufferedWriter) -> T): T { +public inline fun Path.useAtomicBufferedWriter(vararg options: OpenOption, f: (BufferedWriter) -> T): T { return atomicWrite { path -> Files.newBufferedWriter(path, *options).use { writer -> f(writer) @@ -124,7 +124,11 @@ inline fun Path.useAtomicBufferedWriter(vararg options: OpenOption, f: (Buff } } -inline fun Path.useAtomicBufferedWriter(cs: Charset, vararg options: OpenOption, f: (BufferedWriter) -> T): T { +public inline fun Path.useAtomicBufferedWriter( + cs: Charset, + vararg options: OpenOption, + f: (BufferedWriter) -> T +): T { return atomicWrite { path -> Files.newBufferedWriter(path, cs, *options).use { writer -> f(writer) @@ -132,7 +136,7 @@ inline fun Path.useAtomicBufferedWriter(cs: Charset, vararg options: OpenOpt } } -inline fun Path.useAtomicOutputStream(vararg options: OpenOption, f: (OutputStream) -> T): T { +public inline fun Path.useAtomicOutputStream(vararg options: OpenOption, f: (OutputStream) -> T): T { return atomicWrite { path -> Files.newOutputStream(path, *options).use { output -> f(output) diff --git a/util/src/main/java/dev/openrs2/util/io/SkipOutputStream.kt b/util/src/main/java/dev/openrs2/util/io/SkipOutputStream.kt index 1b3bca59b7..9ac37510cd 100644 --- a/util/src/main/java/dev/openrs2/util/io/SkipOutputStream.kt +++ b/util/src/main/java/dev/openrs2/util/io/SkipOutputStream.kt @@ -2,7 +2,7 @@ package dev.openrs2.util.io import java.io.OutputStream -class SkipOutputStream(private val out: OutputStream, private var skipBytes: Long) : OutputStream() { +public class SkipOutputStream(private val out: OutputStream, private var skipBytes: Long) : OutputStream() { override fun write(b: Int) { if (skipBytes == 0L) { out.write(b) diff --git a/yaml/src/main/java/dev/openrs2/yaml/ObjectMapperProvider.kt b/yaml/src/main/java/dev/openrs2/yaml/ObjectMapperProvider.kt index 4e41c7971c..c0aff75f8a 100644 --- a/yaml/src/main/java/dev/openrs2/yaml/ObjectMapperProvider.kt +++ b/yaml/src/main/java/dev/openrs2/yaml/ObjectMapperProvider.kt @@ -8,7 +8,7 @@ import com.fasterxml.jackson.module.kotlin.registerKotlinModule import javax.inject.Inject import javax.inject.Provider -class ObjectMapperProvider @Inject constructor( +public class ObjectMapperProvider @Inject constructor( private val modules: Set<@JvmSuppressWildcards Module> ) : Provider { override fun get(): ObjectMapper { diff --git a/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt b/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt index f534687d5a..956ae73a30 100644 --- a/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt +++ b/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt @@ -6,7 +6,7 @@ import com.google.inject.AbstractModule import com.google.inject.Scopes import com.google.inject.multibindings.Multibinder -object YamlModule : AbstractModule() { +public object YamlModule : AbstractModule() { override fun configure() { Multibinder.newSetBinder(binder(), Module::class.java)