Use private companion objects where possible

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent deac3306e8
commit ccf7056a93
  1. 2
      asm/src/main/java/dev/openrs2/asm/filter/GlobMemberFilter.kt
  2. 2
      bundler/src/main/java/dev/openrs2/bundler/Bundler.kt
  3. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/BufferSizeTransformer.kt
  4. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/CachePathTransformer.kt
  5. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/DomainTransformer.kt
  6. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/HostCheckTransformer.kt
  7. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/LoadLibraryTransformer.kt
  8. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/MacResizeTransformer.kt
  9. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/MemoryAllocationTransformer.kt
  10. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/NameTransformer.kt
  11. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/PlatformDetectionTransformer.kt
  12. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/PublicKeyTransformer.kt
  13. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/ResourceTransformer.kt
  14. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/RightClickTransformer.kt
  15. 2
      bundler/src/main/java/dev/openrs2/bundler/transform/TypoTransformer.kt
  16. 2
      conf/src/main/java/dev/openrs2/conf/Config.kt
  17. 2
      conf/src/main/java/dev/openrs2/conf/ConfigProvider.kt
  18. 2
      crypto/src/main/java/dev/openrs2/crypto/RsaKeyProvider.kt
  19. 2
      decompiler/src/main/java/dev/openrs2/decompiler/DecompileCommand.kt
  20. 2
      decompiler/src/main/java/dev/openrs2/decompiler/Decompiler.kt
  21. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/AstDeobfuscator.kt
  22. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/BitMaskTransformer.kt
  23. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/ComplementTransformer.kt
  24. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/EncloseTransformer.kt
  25. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/GlTransformer.kt
  26. 2
      deob-ast/src/main/java/dev/openrs2/deob/ast/transform/NewInstanceTransformer.kt
  27. 2
      deob-map/src/main/java/dev/openrs2/deob/map/NameMapProvider.kt
  28. 2
      deob/src/main/java/dev/openrs2/deob/Deobfuscator.kt
  29. 2
      deob/src/main/java/dev/openrs2/deob/analysis/IntInterpreter.kt
  30. 2
      deob/src/main/java/dev/openrs2/deob/transform/BitShiftTransformer.kt
  31. 2
      deob/src/main/java/dev/openrs2/deob/transform/BitwiseOpTransformer.kt
  32. 2
      deob/src/main/java/dev/openrs2/deob/transform/BundlerTransformer.kt
  33. 2
      deob/src/main/java/dev/openrs2/deob/transform/ClassLiteralTransformer.kt
  34. 2
      deob/src/main/java/dev/openrs2/deob/transform/ConstantArgTransformer.kt
  35. 2
      deob/src/main/java/dev/openrs2/deob/transform/CounterTransformer.kt
  36. 2
      deob/src/main/java/dev/openrs2/deob/transform/EmptyClassTransformer.kt
  37. 2
      deob/src/main/java/dev/openrs2/deob/transform/ExceptionTracingTransformer.kt
  38. 2
      deob/src/main/java/dev/openrs2/deob/transform/FieldOrderTransformer.kt
  39. 2
      deob/src/main/java/dev/openrs2/deob/transform/FinalTransformer.kt
  40. 2
      deob/src/main/java/dev/openrs2/deob/transform/InvokeSpecialTransformer.kt
  41. 2
      deob/src/main/java/dev/openrs2/deob/transform/MethodOrderTransformer.kt
  42. 2
      deob/src/main/java/dev/openrs2/deob/transform/MonitorTransformer.kt
  43. 2
      deob/src/main/java/dev/openrs2/deob/transform/OpaquePredicateTransformer.kt
  44. 2
      deob/src/main/java/dev/openrs2/deob/transform/OriginalNameTransformer.kt
  45. 2
      deob/src/main/java/dev/openrs2/deob/transform/OriginalPcRestoreTransformer.kt
  46. 2
      deob/src/main/java/dev/openrs2/deob/transform/OriginalPcSaveTransformer.kt
  47. 2
      deob/src/main/java/dev/openrs2/deob/transform/OverrideTransformer.kt
  48. 2
      deob/src/main/java/dev/openrs2/deob/transform/ResetTransformer.kt
  49. 2
      deob/src/main/java/dev/openrs2/deob/transform/StaticScramblingTransformer.kt
  50. 2
      deob/src/main/java/dev/openrs2/deob/transform/UnusedArgTransformer.kt
  51. 2
      deob/src/main/java/dev/openrs2/deob/transform/UnusedLocalTransformer.kt
  52. 2
      deob/src/main/java/dev/openrs2/deob/transform/VisibilityTransformer.kt
  53. 2
      util/src/main/java/dev/openrs2/util/io/DeterministicJarOutputStream.kt

@ -13,7 +13,7 @@ class GlobMemberFilter(@Suppress("CanBeParameter") private val patterns: List<Me
return compiledPatterns.any { it.owner.matches(owner) && it.name.matches(name) && it.desc.matches(desc) }
}
companion object {
private companion object {
private fun compile(member: MemberRef): CompiledPattern {
return CompiledPattern(
Glob.compileClass(member.owner),

@ -146,7 +146,7 @@ class Bundler @Inject constructor(
glLoader.write(output.resolve("loader_gl.jar"), SignedJarLibraryWriter(signedManifest, keyStore), glClassPath)
}
companion object {
private companion object {
private val logger = InlineLogger()
private val APPLICATION_NAME = Attributes.Name("Application-Name")

@ -58,7 +58,7 @@ class BufferSizeTransformer : Transformer() {
logger.info { "Resized $buffersResized buffers to 65536 bytes" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val GPP1_POS_MATCHER = InsnMatcher.compile("LDC (INVOKESPECIAL | INVOKEVIRTUAL) GETSTATIC")
private val NEW_BUFFER_MATCHER = InsnMatcher.compile("NEW DUP (SIPUSH | LDC) INVOKESPECIAL PUTSTATIC")

@ -50,7 +50,7 @@ class CachePathTransformer @Inject constructor(
logger.info { "Updated $paths cache paths" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -45,7 +45,7 @@ class DomainTransformer @Inject constructor(
logger.info { "Replaced $domains domains" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -62,7 +62,7 @@ class HostCheckTransformer : Transformer() {
logger.info { "Removed $hostChecks host checks" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val GET_HOST_MATCHER = InsnMatcher.compile("INVOKEVIRTUAL INVOKEVIRTUAL INVOKEVIRTUAL")
}

@ -41,7 +41,7 @@ class LoadLibraryTransformer : Transformer() {
logger.info { "Replaced $jnilibs jnilibs with dylibs and removed $amd64Checks amd64 jagmisc checks" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val AMD64_CHECK_MATCHER =
InsnMatcher.compile("GETSTATIC LDC INVOKEVIRTUAL IFNE GETSTATIC LDC INVOKEVIRTUAL IFNE")

@ -68,7 +68,7 @@ class MacResizeTransformer : Transformer() {
logger.info { "Removed $branchesRemoved branches to macOS-specific resize logic" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val DETECT_MAC_MATCHER = InsnMatcher.compile("GETSTATIC LDC INVOKEVIRTUAL (IFEQ | IFNE)")
}

@ -56,7 +56,7 @@ class MemoryAllocationTransformer : Transformer() {
logger.info { "Zeroed $usedMemoryExprsZeroed used memory expressions" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val USED_MEMORY_MATCHER = InsnMatcher.compile("ALOAD INVOKEVIRTUAL ALOAD INVOKEVIRTUAL LSUB")

@ -46,7 +46,7 @@ class NameTransformer @Inject constructor(
logger.info { "Replaced $names operator and game names" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -151,7 +151,7 @@ class PlatformDetectionTransformer : Transformer() {
logger.info { "Replaced $glBlocks jaggl and $miscBlocks jagmisc platform detection blocks" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val GL_PLATFORM_DETECTION_MATCHER = InsnMatcher.compile(
"""

@ -46,7 +46,7 @@ class PublicKeyTransformer @Inject constructor(private val key: RSAPrivateCrtKey
logger.info { "Replaced $exponents exponents and $moduli moduli" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private const val JAGEX_EXPONENT =
"58778699976184461502525193738213253649000149147835990136706041084440742975821"

@ -182,7 +182,7 @@ class ResourceTransformer(
logger.info { "Replaced $glBlocks jaggl and $miscBlocks jagmisc resource constructor blocks" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private const val RESOURCE_CONSTRUCTOR = """

@ -53,7 +53,7 @@ class RightClickTransformer : Transformer() {
logger.info { "Replaced $metaDownCalls isMetaDown calls with getModifiersEx" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -36,7 +36,7 @@ class TypoTransformer : Transformer() {
logger.info { "Fixed $errorsFixed typographical errors" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -13,7 +13,7 @@ data class Config(
internalOperator = operator.toInternalName()
}
companion object {
private companion object {
private val INTERNAL_NAME_REGEX = Regex("(?i)[^a-z0-9]+")
private fun String.toInternalName(): String {

@ -17,7 +17,7 @@ class ConfigProvider @Inject constructor(private val mapper: ObjectMapper) : Pro
}
}
companion object {
private companion object {
private val CONFIG_PATH = Paths.get("etc/config.yaml")
private val EXAMPLE_CONFIG_PATH = Paths.get("etc/config.example.yaml")
}

@ -16,7 +16,7 @@ class RsaKeyProvider : Provider<RSAPrivateCrtKeyParameters> {
}
}
companion object {
private companion object {
private val PATH = Paths.get("etc/game.key")
}
}

@ -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$")
}
}

@ -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"

@ -75,7 +75,7 @@ class AstDeobfuscator(private val modules: List<Path>) {
}
}
companion object {
private companion object {
private val logger = InlineLogger()
private val TRANSFORMERS = listOf(

@ -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

@ -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
}

@ -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

@ -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"

@ -22,7 +22,7 @@ class NewInstanceTransformer : Transformer() {
}
}
companion object {
private companion object {
private val CONSTRUCTOR_METHODS = setOf("getConstructor", "getDeclaredConstructor")
}
}

@ -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"
}

@ -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()
}
}

@ -145,7 +145,7 @@ class IntInterpreter(private val args: Array<IntValueSet>) : Interpreter<IntValu
}
}
companion object {
private companion object {
private const val MAX_TRACKED_VALUES = 1
}
}

@ -47,7 +47,7 @@ class BitShiftTransformer : Transformer() {
logger.info { "Simplified $simplified bit shifts" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val CONST_SHIFT_MATCHER =
InsnMatcher.compile("(ICONST | BIPUSH | SIPUSH | LDC) (ISHL | ISHR | IUSHR | LSHL | LSHR | LUSHR)")

@ -81,7 +81,7 @@ class BitwiseOpTransformer : Transformer() {
logger.info { "Inlined $inlinedOps bitwise ops and removed ${methodOps.size} redundant methods" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val BITWISE_OP_MATCHER = InsnMatcher.compile("^ILOAD ILOAD (IXOR | IAND | IOR) IRETURN$")
private const val BITWISE_OP_DESC = "(II)I"

@ -18,7 +18,7 @@ class BundlerTransformer @Inject constructor(
}
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -110,7 +110,7 @@ class ClassLiteralTransformer : Transformer() {
logger.info { "Updated $classLiterals class literals to Java 5 style" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val CLASS_FOR_NAME_MATCHER = InsnMatcher.compile(
"""

@ -307,7 +307,7 @@ class ConstantArgTransformer @Inject constructor(private val profile: Profile) :
logger.info { "Simplified $branchesSimplified branches and inlined $constantsInlined constants" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -113,7 +113,7 @@ class CounterTransformer : Transformer() {
logger.info { "Removed ${counters.size} counters" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val RESET_PATTERN = InsnMatcher.compile("ICONST_0 PUTSTATIC")
private val INCREMENT_PATTERN = InsnMatcher.compile("GETSTATIC ICONST_1 IADD PUTSTATIC")

@ -102,7 +102,7 @@ class EmptyClassTransformer : Transformer() {
logger.info { "Removed $removedClasses unused classes" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -59,7 +59,7 @@ class ExceptionTracingTransformer : Transformer() {
logger.info { "Removed $tracingTryCatches tracing try/catch blocks" }
}
companion object {
private companion object {
private val logger = InlineLogger()
private val CATCH_MATCHER = InsnMatcher.compile(
"""

@ -18,7 +18,7 @@ class FieldOrderTransformer : Transformer() {
return false
}
companion object {
private companion object {
private const val CONSTRUCTOR = "<init>"
private const val STATIC_CONSTRUCTOR = "<clinit>"
private val STATIC_COMPARATOR = Comparator<FieldNode> { a, b ->

@ -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()
}
}

@ -86,7 +86,7 @@ class InvokeSpecialTransformer : Transformer() {
logger.info { "Replaced $invokeSpecialsReplaced INVOKESPECIALs with INVOKEVIRTUAL" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -15,7 +15,7 @@ class MethodOrderTransformer : Transformer() {
return false
}
companion object {
private companion object {
private val STATIC_COMPARATOR = Comparator<MethodNode> { a, b ->
val aStatic = a.access and Opcodes.ACC_STATIC != 0
val bStatic = b.access and Opcodes.ACC_STATIC != 0

@ -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

@ -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(
"""

@ -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)

@ -51,7 +51,7 @@ class OriginalPcRestoreTransformer : Transformer() {
logger.info { "Restored $originalPcsRestored original instruction indexes" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -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()
}
}

@ -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)
}

@ -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? {

@ -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

@ -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,

@ -54,7 +54,7 @@ class UnusedLocalTransformer : Transformer() {
logger.info { "Removed $localsRemoved unused local variables" }
}
companion object {
private companion object {
private val logger = InlineLogger()
}
}

@ -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

@ -22,7 +22,7 @@ class DeterministicJarOutputStream : JarOutputStream {
super.putNextEntry(ze)
}
companion object {
private companion object {
private val UNIX_EPOCH = FileTime.fromMillis(0)
}
}

Loading…
Cancel
Save