diff --git a/buildSrc/src/main/java/Versions.kt b/buildSrc/src/main/java/Versions.kt index 04e4f2da..819355b6 100644 --- a/buildSrc/src/main/java/Versions.kt +++ b/buildSrc/src/main/java/Versions.kt @@ -11,7 +11,7 @@ object Versions { const val guice = "4.2.3" const val inlineLogger = "1.0.2" const val jackson = "2.11.0" - const val javaParser = "3.15.22" + const val javaParser = "3.16.1" const val jdom = "2.0.6" const val jgrapht = "1.4.0" const val jimfs = "1.1" 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 c71b773f..10436698 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 @@ -2,6 +2,7 @@ package dev.openrs2.deob.ast.transform import com.github.javaparser.ast.CompilationUnit import com.github.javaparser.ast.expr.MethodCallExpr +import dev.openrs2.deob.ast.util.isClass import dev.openrs2.deob.ast.util.walk import javax.inject.Singleton @@ -17,14 +18,10 @@ class NewInstanceTransformer : Transformer() { } expr.scope.ifPresent { scope -> - if (!scope.isMethodCallExpr || scope.asMethodCallExpr().nameAsString !in CONSTRUCTOR_METHODS) { + if (scope.calculateResolvedType().isClass()) { expr.setScope(MethodCallExpr(scope.clone(), "getDeclaredConstructor")) } } } } - - private companion object { - private val CONSTRUCTOR_METHODS = setOf("getConstructor", "getDeclaredConstructor") - } } 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 4e8f8814..a0a12a39 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 @@ -5,3 +5,7 @@ import com.github.javaparser.resolution.types.ResolvedType fun ResolvedType.isString(): Boolean { return isReferenceType && asReferenceType().qualifiedName == "java.lang.String" } + +fun ResolvedType.isClass(): Boolean { + return isReferenceType && asReferenceType().qualifiedName == "java.lang.Class" +}