forked from openrs2/openrs2
Might need to move to the bytecode deobfuscator if public boxed type constructors are removed from future JDKs, but for now it's easier to do this on the AST level.bzip2
parent
08caea8289
commit
328b122330
@ -0,0 +1,21 @@ |
|||||||
|
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 com.github.javaparser.ast.expr.ObjectCreationExpr; |
||||||
|
import com.github.javaparser.ast.expr.TypeExpr; |
||||||
|
import dev.openrs2.deob.ast.util.NodeUtils; |
||||||
|
|
||||||
|
public final class ValueOfTransformer extends Transformer { |
||||||
|
@Override |
||||||
|
public void transform(CompilationUnit unit) { |
||||||
|
NodeUtils.walk(unit, Node.TreeTraversal.POSTORDER, ObjectCreationExpr.class, expr -> { |
||||||
|
if (!expr.getType().isBoxedType()) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
expr.replace(new MethodCallExpr(new TypeExpr(expr.getType()), "valueOf", expr.getArguments())); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue