Make package-private classes, methods and fields public

This will make refactoring the client code into packages easier.
master
Graham 5 years ago
parent f6f810de2e
commit 446a72abc5
  1. 28
      deob/src/main/java/dev/openrs2/deob/transform/AccessTransformer.java

@ -5,6 +5,7 @@ import dev.openrs2.asm.classpath.Library;
import dev.openrs2.asm.transform.Transformer; import dev.openrs2.asm.transform.Transformer;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.FieldNode;
import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.tree.MethodNode;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -12,15 +13,39 @@ import org.slf4j.LoggerFactory;
public final class AccessTransformer extends Transformer { public final class AccessTransformer extends Transformer {
private static final Logger logger = LoggerFactory.getLogger(AccessTransformer.class); private static final Logger logger = LoggerFactory.getLogger(AccessTransformer.class);
private int redundantFinals; private int redundantFinals, packagePrivate;
@Override @Override
protected void preTransform(ClassPath classPath) { protected void preTransform(ClassPath classPath) {
redundantFinals = 0; redundantFinals = 0;
packagePrivate = 0;
}
@Override
protected boolean transformClass(ClassPath classPath, Library library, ClassNode clazz) {
if ((clazz.access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE)) == 0) {
clazz.access |= Opcodes.ACC_PUBLIC;
packagePrivate++;
}
return false;
}
@Override
protected boolean transformField(ClassPath classPath, Library library, ClassNode clazz, FieldNode field) {
if ((field.access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE)) == 0) {
field.access |= Opcodes.ACC_PUBLIC;
packagePrivate++;
}
return false;
} }
@Override @Override
protected boolean preTransformMethod(ClassPath classPath, Library library, ClassNode clazz, MethodNode method) { protected boolean preTransformMethod(ClassPath classPath, Library library, ClassNode clazz, MethodNode method) {
if ((method.access & (Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE)) == 0) {
method.access |= Opcodes.ACC_PUBLIC;
packagePrivate++;
}
if ((method.access & Opcodes.ACC_FINAL) == 0) { if ((method.access & Opcodes.ACC_FINAL) == 0) {
return false; return false;
} }
@ -35,5 +60,6 @@ public final class AccessTransformer extends Transformer {
@Override @Override
protected void postTransform(ClassPath classPath) { protected void postTransform(ClassPath classPath) {
logger.info("Removed {} redundant final modifiers", redundantFinals); logger.info("Removed {} redundant final modifiers", redundantFinals);
logger.info("Made {} package-private classes, fields and methods public", packagePrivate);
} }
} }

Loading…
Cancel
Save