forked from openrs2/openrs2
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
package dev.openrs2.deob.transform;
|
|
|
|
import dev.openrs2.asm.classpath.ClassPath;
|
|
import dev.openrs2.asm.classpath.Library;
|
|
import dev.openrs2.asm.transform.Transformer;
|
|
import org.objectweb.asm.Opcodes;
|
|
import org.objectweb.asm.tree.ClassNode;
|
|
import org.objectweb.asm.tree.MethodNode;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
public final class AccessTransformer extends Transformer {
|
|
private static final Logger logger = LoggerFactory.getLogger(AccessTransformer.class);
|
|
|
|
private int redundantFinals;
|
|
|
|
@Override
|
|
protected void preTransform(ClassPath classPath) {
|
|
redundantFinals = 0;
|
|
}
|
|
|
|
@Override
|
|
protected boolean preTransformMethod(ClassPath classPath, Library library, ClassNode clazz, MethodNode method) {
|
|
if ((method.access & Opcodes.ACC_FINAL) == 0) {
|
|
return false;
|
|
}
|
|
|
|
if ((method.access & (Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC)) != 0) {
|
|
method.access &= ~Opcodes.ACC_FINAL;
|
|
redundantFinals++;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
protected void postTransform(ClassPath classPath) {
|
|
logger.info("Removed {} redundant final modifiers", redundantFinals);
|
|
}
|
|
}
|
|
|