forked from openrs2/openrs2
Again, if these are removed from a future JDK we'll need to move this transform to the bytecode deobfuscator.bzip2
parent
328b122330
commit
bcbf4b6178
@ -0,0 +1,25 @@ |
|||||||
|
package dev.openrs2.deob.ast.transform; |
||||||
|
|
||||||
|
import com.github.javaparser.ast.CompilationUnit; |
||||||
|
import com.github.javaparser.ast.Node; |
||||||
|
import com.github.javaparser.ast.expr.MethodCallExpr; |
||||||
|
import dev.openrs2.deob.ast.util.NodeUtils; |
||||||
|
|
||||||
|
public final class NewInstanceTransformer extends Transformer { |
||||||
|
@Override |
||||||
|
public void transform(CompilationUnit unit) { |
||||||
|
NodeUtils.walk(unit, Node.TreeTraversal.POSTORDER, MethodCallExpr.class, expr -> { |
||||||
|
if (!expr.getNameAsString().equals("newInstance")) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
expr.getScope().ifPresent(scope -> { |
||||||
|
if (scope.isMethodCallExpr() && scope.asMethodCallExpr().getNameAsString().equals("getConstructor")) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
expr.setScope(new MethodCallExpr(scope.clone(), "getDeclaredConstructor")); |
||||||
|
}); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue