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 b8e60728e8..6827f15535 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 a55b9044f6..40f6b0a75f 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 cf29f778d5..8e8ac4304a 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 4369851695..5298744f26 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 0da3ae86aa..657e442603 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 2d54fa1f69..78cc0b0165 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 39194d65be..58ee8b3880 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 739975b87e..5ac5fa216c 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 56d8c25e02..10e9af88bb 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 85cd5aa8cd..598e3dec0a 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 24ff4cd1e2..b6488b7ac7 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 920b12eecc..02d132adc9 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 b1662aa9b7..4c1efb72fe 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 734cc5435b..e6105d4914 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 23057a9fca..e16d62e4b4 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 b1d9aac6ed..a88db6f942 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 1dd6aeb0ad..718a5a1041 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 d5142008e2..6e99dfc6d7 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 7d55f3c135..5984566ade 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 a7077a3c1e..3ca9d5742f 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 282c29751e..311f869eb7 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 2d59aa8b36..6b4e43e4b1 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 36ecdc083a..f819e5a83b 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 9297e72274..0960d58a0e 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 5f6078a768..b1c4de7320 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 332aacc8c9..aa246425c6 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 71d2a4791b..ffd46e99ef 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) } }