From ccf7056a93d60459990ff1d96e06a8e853a59607 Mon Sep 17 00:00:00 2001 From: Graham Date: Sun, 10 May 2020 10:23:28 +0100 Subject: [PATCH] Use private companion objects where possible Signed-off-by: Graham --- asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt | 2 +- bundler/src/main/java/dev/openrs2/bundler/Bundler.kt | 2 +- .../java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt | 2 +- .../java/dev/openrs2/bundler/transform/CachePathTransformer.kt | 2 +- .../java/dev/openrs2/bundler/transform/DomainTransformer.kt | 2 +- .../java/dev/openrs2/bundler/transform/HostCheckTransformer.kt | 2 +- .../dev/openrs2/bundler/transform/LoadLibraryTransformer.kt | 2 +- .../java/dev/openrs2/bundler/transform/MacResizeTransformer.kt | 2 +- .../openrs2/bundler/transform/MemoryAllocationTransformer.kt | 2 +- .../main/java/dev/openrs2/bundler/transform/NameTransformer.kt | 2 +- .../openrs2/bundler/transform/PlatformDetectionTransformer.kt | 2 +- .../java/dev/openrs2/bundler/transform/PublicKeyTransformer.kt | 2 +- .../java/dev/openrs2/bundler/transform/ResourceTransformer.kt | 2 +- .../java/dev/openrs2/bundler/transform/RightClickTransformer.kt | 2 +- .../main/java/dev/openrs2/bundler/transform/TypoTransformer.kt | 2 +- conf/src/main/java/dev/openrs2/conf/Config.kt | 2 +- conf/src/main/java/dev/openrs2/conf/ConfigProvider.kt | 2 +- crypto/src/main/java/dev/openrs2/crypto/RsaKeyProvider.kt | 2 +- .../src/main/java/dev/openrs2/decompiler/DecompileCommand.kt | 2 +- decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt | 2 +- deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt | 2 +- .../java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt | 2 +- .../dev/openrs2/deob/ast/transform/ComplementTransformer.kt | 2 +- .../java/dev/openrs2/deob/ast/transform/EncloseTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/ast/transform/GlTransformer.kt | 2 +- .../dev/openrs2/deob/ast/transform/NewInstanceTransformer.kt | 2 +- deob-map/src/main/java/dev/openrs2/deob/map/NameMapProvider.kt | 2 +- deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt | 2 +- deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt | 2 +- .../main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/transform/BundlerTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/ConstantArgTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/transform/CounterTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/EmptyClassTransformer.kt | 2 +- .../dev/openrs2/deob/transform/ExceptionTracingTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/FieldOrderTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/transform/FinalTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/MethodOrderTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/transform/MonitorTransformer.kt | 2 +- .../dev/openrs2/deob/transform/OpaquePredicateTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/OriginalNameTransformer.kt | 2 +- .../dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt | 2 +- .../dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/transform/OverrideTransformer.kt | 2 +- .../main/java/dev/openrs2/deob/transform/ResetTransformer.kt | 2 +- .../dev/openrs2/deob/transform/StaticScramblingTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/UnusedArgTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt | 2 +- .../java/dev/openrs2/deob/transform/VisibilityTransformer.kt | 2 +- .../java/dev/openrs2/util/io/DeterministicJarOutputStream.kt | 2 +- 53 files changed, 53 insertions(+), 53 deletions(-) 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 b8e60728..6827f155 100644 --- a/asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt +++ b/asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt @@ -13,7 +13,7 @@ class GlobMemberFilter(@Suppress("CanBeParameter") private val patterns: List { } } - companion object { + private companion object { private val PATH = Paths.get("etc/game.key") } } diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt b/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt index a55b9044..40f6b0a7 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt @@ -31,7 +31,7 @@ class DecompileCommand : CliktCommand(name = "decompile") { return Paths.get("nonfree").resolve(dir).resolve("src/main/java") } - companion object { + private companion object { private val JAR_SUFFIX_REGEX = Regex("(?:_gl)?[.]jar$") } } diff --git a/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt b/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt index cf29f778..8e8ac430 100644 --- a/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt +++ b/decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt @@ -23,7 +23,7 @@ class Decompiler( io.close() } - companion object { + private companion object { private val OPTIONS = mapOf( IFernflowerPreferences.INDENT_STRING to "\t", IFernflowerPreferences.SYNTHETIC_NOT_SET to "1" 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 43698516..5298744f 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 @@ -75,7 +75,7 @@ class AstDeobfuscator(private val modules: List) { } } - companion object { + private companion object { private val logger = InlineLogger() private val TRANSFORMERS = listOf( 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 0da3ae86..657e4426 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 @@ -59,7 +59,7 @@ class BitMaskTransformer : Transformer() { } } - companion object { + private companion object { private val SHIFT_OPS = setOf( BinaryExpr.Operator.SIGNED_RIGHT_SHIFT, BinaryExpr.Operator.UNSIGNED_RIGHT_SHIFT 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 2d54fa1f..78cc0b01 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 @@ -31,7 +31,7 @@ class ComplementTransformer : Transformer() { } } - companion object { + private companion object { private fun Expression.isComplement(): Boolean { return isUnaryExpr && asUnaryExpr().operator == UnaryExpr.Operator.BITWISE_COMPLEMENT } 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 39194d65..58ee8b38 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 @@ -124,7 +124,7 @@ class EncloseTransformer : Transformer() { } } - companion object { + private companion object { private fun encloseLeft(parent: Expression, child: Expression) { val parentOp = Op.from(parent) ?: throw IllegalArgumentException() val childOp = Op.from(child) ?: return 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 739975b8..5ac5fa21 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 @@ -306,7 +306,7 @@ class GlTransformer(private val registry: GlRegistry = GlRegistry.parse()) : Tra } } - companion object { + private companion object { private val logger = InlineLogger() private const val GL_METHOD_PREFIX = "gl" private const val GL_CLASS_UNQUALIFIED = "GL" 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 56d8c25e..10e9af88 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 @@ -22,7 +22,7 @@ class NewInstanceTransformer : Transformer() { } } - companion object { + private companion object { private val CONSTRUCTOR_METHODS = setOf("getConstructor", "getDeclaredConstructor") } } diff --git a/deob-map/src/main/java/dev/openrs2/deob/map/NameMapProvider.kt b/deob-map/src/main/java/dev/openrs2/deob/map/NameMapProvider.kt index 85cd5aa8..598e3dec 100644 --- a/deob-map/src/main/java/dev/openrs2/deob/map/NameMapProvider.kt +++ b/deob-map/src/main/java/dev/openrs2/deob/map/NameMapProvider.kt @@ -25,7 +25,7 @@ class NameMapProvider @Inject constructor(private val mapper: ObjectMapper) : Pr return Files.isRegularFile(path) && path.fileName.toString().endsWith(YAML_SUFFIX) } - companion object { + private companion object { private val PATH = Paths.get("share/deob/map") private const val YAML_SUFFIX = ".yaml" } diff --git a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt index 24ff4cd1..b6488b7a 100644 --- a/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt +++ b/deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt @@ -120,7 +120,7 @@ class Deobfuscator @Inject constructor( unsignedClient.write(output.resolve("runescape_unsigned.jar"), JarLibraryWriter, unsignedClassPath) } - companion object { + private companion object { private val logger = InlineLogger() } } 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 920b12ee..02d132ad 100644 --- a/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt +++ b/deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt @@ -145,7 +145,7 @@ class IntInterpreter(private val args: Array) : Interpreter { a, b -> 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 b1662aa9..4c1efb72 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt @@ -113,7 +113,7 @@ class FinalTransformer : Transformer() { logger.info { "Updated final modifier on $classesChanged classes and $methodsChanged methods" } } - companion object { + private companion object { private val logger = InlineLogger() } } 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 734cc543..e6105d49 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt @@ -86,7 +86,7 @@ class InvokeSpecialTransformer : Transformer() { logger.info { "Replaced $invokeSpecialsReplaced INVOKESPECIALs with INVOKEVIRTUAL" } } - companion object { + private companion object { private val logger = InlineLogger() } } 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 23057a9f..e16d62e4 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt @@ -15,7 +15,7 @@ class MethodOrderTransformer : Transformer() { return false } - companion object { + private companion object { private val STATIC_COMPARATOR = Comparator { a, b -> val aStatic = a.access and Opcodes.ACC_STATIC != 0 val bStatic = b.access and Opcodes.ACC_STATIC != 0 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 b1d9aac6..a88db6f9 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt @@ -131,7 +131,7 @@ class MonitorTransformer : Transformer() { logger.info { "Replaced $loadsReplaced ASTORE ALOAD sequences with DUP ASTORE" } } - companion object { + private companion object { private val logger = InlineLogger() // these regexes rely on JSRInlinerAdapter running first 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 1dd6aeb0..718a5a10 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt @@ -115,7 +115,7 @@ class OpaquePredicateTransformer : Transformer() { logger.info { "Removed $opaquePredicates opaque predicates and $stores redundant stores" } } - companion object { + private companion object { private val logger = InlineLogger() private val FLOW_OBSTRUCTOR_INITIALIZER_MATCHER = InsnMatcher.compile( """ 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 d5142008..6e99dfc6 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt @@ -67,7 +67,7 @@ class OriginalNameTransformer : Transformer() { return false } - companion object { + private companion object { private fun createOriginalClassAnnotation(name: String): AnnotationNode { val annotation = AnnotationNode(Type.getDescriptor(OriginalClass::class.java)) annotation.values = listOf("value", name) 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 7d55f3c1..5984566a 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt @@ -51,7 +51,7 @@ class OriginalPcRestoreTransformer : Transformer() { logger.info { "Restored $originalPcsRestored original instruction indexes" } } - companion object { + private companion object { private val logger = InlineLogger() } } 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 a7077a3c..3ca9d574 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt @@ -22,7 +22,7 @@ class OriginalPcSaveTransformer : Transformer() { logger.info { "Saved ${classPath.originalPcs.size} original instruction indexes" } } - companion object { + private companion object { private val logger = InlineLogger() } } 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 282c2975..311f869e 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt @@ -51,7 +51,7 @@ class OverrideTransformer : Transformer() { logger.info { "Added $overrides override annotations" } } - companion object { + private companion object { private val logger = InlineLogger() private val OVERRIDE_DESC: String = Type.getDescriptor(Override::class.java) } 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 2d59aa8b..6b4e43e4 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt @@ -59,7 +59,7 @@ class ResetTransformer : Transformer() { logger.info { "Removed ${resetMethods.size} reset methods" } } - companion object { + private companion object { private val logger = InlineLogger() private fun findMasterReset(method: MethodNode): MemberRef? { diff --git a/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt b/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt index 36ecdc08..f819e5a8 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt @@ -213,7 +213,7 @@ class StaticScramblingTransformer @Inject constructor(private val profile: Profi logger.info { "Moved ${fieldClasses.size} fields and ${methodClasses.size} methods" } } - companion object { + private companion object { private val logger = InlineLogger() private const val MAX_FIELDS = 500 private const val MAX_METHODS = 50 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 9297e722..0960d58a 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt @@ -171,7 +171,7 @@ class UnusedArgTransformer @Inject constructor(private val profile: Profile) : T logger.info { "Removed $deletedArgs unused arguments" } } - companion object { + private companion object { private val logger = InlineLogger() private val INT_SORTS = setOf( Type.BOOLEAN, 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 5f6078a7..b1c4de73 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt @@ -54,7 +54,7 @@ class UnusedLocalTransformer : Transformer() { logger.info { "Removed $localsRemoved unused local variables" } } - companion object { + private companion object { private val logger = InlineLogger() } } 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 332aacc8..aa246425 100644 --- a/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt +++ b/deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt @@ -154,7 +154,7 @@ class VisibilityTransformer @Inject constructor(private val profile: Profile) : } } - companion object { + private companion object { private val logger = InlineLogger() private const val VISIBILITY_FLAGS = Opcodes.ACC_PUBLIC or Opcodes.ACC_PROTECTED or Opcodes.ACC_PRIVATE 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 71d2a479..ffd46e99 100644 --- a/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt +++ b/util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt @@ -22,7 +22,7 @@ class DeterministicJarOutputStream : JarOutputStream { super.putNextEntry(ze) } - companion object { + private companion object { private val UNIX_EPOCH = FileTime.fromMillis(0) } }