Checkstyle fixes
This commit is contained in:
@@ -51,19 +51,16 @@ import net.runelite.injector.raw.RasterizerHook;
|
||||
import net.runelite.injector.raw.RenderDraw;
|
||||
import net.runelite.injector.raw.ScriptVM;
|
||||
import net.runelite.mapping.Import;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
|
||||
public class Inject
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(Inject.class);
|
||||
|
||||
public static final java.lang.Class<?> CLIENT_CLASS = RSClient.class;
|
||||
|
||||
public static final String API_PACKAGE_BASE = "net.runelite.rs.api.RS";
|
||||
public static final String RL_API_PACKAGE_BASE = "net.runelite.api.";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(Inject.class);
|
||||
private final InjectHookMethod hookMethod = new InjectHookMethod(this);
|
||||
|
||||
private final InjectGetter getters = new InjectGetter(this);
|
||||
@@ -87,34 +84,6 @@ public class Inject
|
||||
this.vanilla = vanilla;
|
||||
}
|
||||
|
||||
public Type getFieldType(Field f)
|
||||
{
|
||||
Type type = f.getType();
|
||||
|
||||
Annotation obfSignature = f.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
|
||||
if (obfSignature != null)
|
||||
{
|
||||
//Annotation exists. Type was updated by us during deobfuscation
|
||||
type = DeobAnnotations.getObfuscatedType(f);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public Signature getMethodSignature(Method m)
|
||||
{
|
||||
Signature signature = m.getDescriptor();
|
||||
|
||||
Annotation obfSignature = m.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
|
||||
if (obfSignature != null)
|
||||
{
|
||||
//Annotation exists. Signature was updated by us during deobfuscation
|
||||
signature = DeobAnnotations.getObfuscatedSignature(m);
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a java.lang.Class to a Type
|
||||
*
|
||||
@@ -173,6 +142,34 @@ public class Inject
|
||||
return Type.getType("L" + c.getName().replace('.', '/') + ";", dimms);
|
||||
}
|
||||
|
||||
public Type getFieldType(Field f)
|
||||
{
|
||||
Type type = f.getType();
|
||||
|
||||
Annotation obfSignature = f.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
|
||||
if (obfSignature != null)
|
||||
{
|
||||
//Annotation exists. Type was updated by us during deobfuscation
|
||||
type = DeobAnnotations.getObfuscatedType(f);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public Signature getMethodSignature(Method m)
|
||||
{
|
||||
Signature signature = m.getDescriptor();
|
||||
|
||||
Annotation obfSignature = m.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
|
||||
if (obfSignature != null)
|
||||
{
|
||||
//Annotation exists. Signature was updated by us during deobfuscation
|
||||
signature = DeobAnnotations.getObfuscatedSignature(m);
|
||||
}
|
||||
|
||||
return signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Signature from a java method
|
||||
*
|
||||
@@ -284,7 +281,7 @@ public class Inject
|
||||
assert !f.isStatic();
|
||||
|
||||
// non static field exported on non exported interface
|
||||
// logger.debug("Non static exported field {} on non exported interface", exportedName);
|
||||
// logger.debug("Non static exported field {} on non exported interface", exportedName);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -325,7 +322,7 @@ public class Inject
|
||||
invokes.process(m, other, implementingClass);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
logger.info("Injected {} getters, {} setters, {} invokers",
|
||||
getters.getInjectedGetters(),
|
||||
setters.getInjectedSetters(), invokes.getInjectedInvokers());
|
||||
@@ -514,10 +511,10 @@ public class Inject
|
||||
}
|
||||
}
|
||||
|
||||
// if (rlApiType == null)
|
||||
// {
|
||||
// throw new InjectionException("RS API type " + rsApiType + " does not extend RL API interface");
|
||||
// }
|
||||
// if (rlApiType == null)
|
||||
// {
|
||||
// throw new InjectionException("RS API type " + rsApiType + " does not extend RL API interface");
|
||||
// }
|
||||
|
||||
final java.lang.Class<?> finalType = rlApiType == null ? rsApiType : rlApiType;
|
||||
|
||||
@@ -539,7 +536,7 @@ public class Inject
|
||||
|
||||
return Type.getType("L" + type.getInternalName().substring(API_PACKAGE_BASE.length()) + ";", type.getDimensions());
|
||||
}
|
||||
|
||||
|
||||
ClassFile findVanillaForInterface(java.lang.Class<?> clazz)
|
||||
{
|
||||
String className = clazz.getName().replace('.', '/');
|
||||
|
||||
@@ -115,19 +115,19 @@ public class InjectConstruct
|
||||
Signature sig = inject.javaMethodToSignature(apiMethod);
|
||||
|
||||
Signature constructorSig = new Signature.Builder()
|
||||
.addArguments(Stream.of(apiMethod.getParameterTypes())
|
||||
.map(arg ->
|
||||
{
|
||||
ClassFile vanilla = inject.findVanillaForInterface(arg);
|
||||
if (vanilla != null)
|
||||
{
|
||||
return new Type("L" + vanilla.getName() + ";");
|
||||
}
|
||||
return Inject.classToType(arg);
|
||||
})
|
||||
.collect(Collectors.toList()))
|
||||
.setReturnType(Type.VOID)
|
||||
.build();
|
||||
.addArguments(Stream.of(apiMethod.getParameterTypes())
|
||||
.map(arg ->
|
||||
{
|
||||
ClassFile vanilla = inject.findVanillaForInterface(arg);
|
||||
if (vanilla != null)
|
||||
{
|
||||
return new Type("L" + vanilla.getName() + ";");
|
||||
}
|
||||
return Inject.classToType(arg);
|
||||
})
|
||||
.collect(Collectors.toList()))
|
||||
.setReturnType(Type.VOID)
|
||||
.build();
|
||||
Method vanillaConstructor = vanillaClass.findMethod("<init>", constructorSig);
|
||||
if (vanillaConstructor == null)
|
||||
{
|
||||
|
||||
@@ -47,16 +47,16 @@ import org.slf4j.LoggerFactory;
|
||||
public class InjectGetter
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(InjectGetter.class);
|
||||
|
||||
|
||||
private final Inject inject;
|
||||
|
||||
|
||||
private int injectedGetters;
|
||||
|
||||
public InjectGetter(Inject inject)
|
||||
{
|
||||
this.inject = inject;
|
||||
}
|
||||
|
||||
|
||||
public void injectGetter(ClassFile clazz, java.lang.reflect.Method method, Field field, Number getter)
|
||||
{
|
||||
// clazz = class file we're injecting the method into.
|
||||
|
||||
@@ -58,23 +58,10 @@ import org.slf4j.LoggerFactory;
|
||||
public class InjectHook
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(InjectHook.class);
|
||||
|
||||
static class HookInfo
|
||||
{
|
||||
String fieldName;
|
||||
String clazz;
|
||||
Method method;
|
||||
boolean before;
|
||||
Number getter;
|
||||
}
|
||||
|
||||
private static final String HOOK_METHOD_SIGNATURE = "(I)V";
|
||||
|
||||
private static final String CLINIT = "<clinit>";
|
||||
|
||||
private final Inject inject;
|
||||
private final Map<Field, HookInfo> hooked = new HashMap<>();
|
||||
|
||||
private int injectedHooks;
|
||||
|
||||
public InjectHook(Inject inject)
|
||||
@@ -272,7 +259,7 @@ public class InjectHook
|
||||
if (hookInfo.getter instanceof Integer)
|
||||
{
|
||||
ins.getInstructions().add(idx++, new LDC(ins, (int) hookInfo.getter));
|
||||
ins.getInstructions().add(idx++,new IMul(ins));
|
||||
ins.getInstructions().add(idx++, new IMul(ins));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -399,4 +386,13 @@ public class InjectHook
|
||||
{
|
||||
return injectedHooks;
|
||||
}
|
||||
|
||||
static class HookInfo
|
||||
{
|
||||
String fieldName;
|
||||
String clazz;
|
||||
Method method;
|
||||
boolean before;
|
||||
Number getter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,10 +49,8 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
public class InjectHookMethod
|
||||
{
|
||||
private static final Logger logger = LoggerFactory.getLogger(InjectHookMethod.class);
|
||||
|
||||
public static final String HOOKS = "net/runelite/client/callback/Hooks";
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(InjectHookMethod.class);
|
||||
private final Inject inject;
|
||||
|
||||
public InjectHookMethod(Inject inject)
|
||||
@@ -115,7 +113,7 @@ public class InjectHookMethod
|
||||
Instructions instructions = vanillaMethod.getCode().getInstructions();
|
||||
|
||||
Signature.Builder builder = new Signature.Builder()
|
||||
.setReturnType(Type.VOID); // Hooks always return void
|
||||
.setReturnType(Type.VOID); // Hooks always return void
|
||||
|
||||
for (Type type : deobMethod.getDescriptor().getArguments())
|
||||
{
|
||||
@@ -164,11 +162,11 @@ public class InjectHookMethod
|
||||
{
|
||||
// Invoke callback
|
||||
invoke = new InvokeStatic(instructions,
|
||||
new net.runelite.asm.pool.Method(
|
||||
new net.runelite.asm.pool.Class(HOOKS),
|
||||
hookName,
|
||||
signature
|
||||
)
|
||||
new net.runelite.asm.pool.Method(
|
||||
new net.runelite.asm.pool.Class(HOOKS),
|
||||
hookName,
|
||||
signature
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -179,11 +177,11 @@ public class InjectHookMethod
|
||||
if (vanillaMethod.isStatic())
|
||||
{
|
||||
invoke = new InvokeStatic(instructions,
|
||||
new net.runelite.asm.pool.Method(
|
||||
new net.runelite.asm.pool.Class("client"), // Static methods are in client
|
||||
hookMethod.getName(),
|
||||
signature
|
||||
)
|
||||
new net.runelite.asm.pool.Method(
|
||||
new net.runelite.asm.pool.Class("client"), // Static methods are in client
|
||||
hookMethod.getName(),
|
||||
signature
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -191,11 +189,11 @@ public class InjectHookMethod
|
||||
// otherwise invoke member function
|
||||
//instructions.addInstruction(insertPos++, new ALoad(instructions, 0));
|
||||
invoke = new InvokeVirtual(instructions,
|
||||
new net.runelite.asm.pool.Method(
|
||||
new net.runelite.asm.pool.Class(vanillaMethod.getClassFile().getName()),
|
||||
hookMethod.getName(),
|
||||
signature
|
||||
)
|
||||
new net.runelite.asm.pool.Method(
|
||||
new net.runelite.asm.pool.Class(vanillaMethod.getClassFile().getName()),
|
||||
hookMethod.getName(),
|
||||
signature
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,11 +67,11 @@ public class InjectInvoker
|
||||
/**
|
||||
* Inject an invoker for a method
|
||||
*
|
||||
* @param m Method in the deobfuscated client to inject an invoker for
|
||||
* @param other Class in the vanilla client of the same class m is a
|
||||
* member of
|
||||
* @param m Method in the deobfuscated client to inject an invoker for
|
||||
* @param other Class in the vanilla client of the same class m is a
|
||||
* member of
|
||||
* @param implementingClass Java class for the API interface the class
|
||||
* will implement
|
||||
* will implement
|
||||
*/
|
||||
public void process(Method m, ClassFile other, java.lang.Class<?> implementingClass)
|
||||
{
|
||||
@@ -108,14 +108,14 @@ public class InjectInvoker
|
||||
assert !m.isStatic();
|
||||
|
||||
// non static exported method on non exported interface, weird.
|
||||
// logger.debug("Non static exported method {} on non exported interface", exportedName);
|
||||
// logger.debug("Non static exported method {} on non exported interface", exportedName);
|
||||
return;
|
||||
}
|
||||
|
||||
java.lang.reflect.Method apiMethod = inject.findImportMethodOnApi(targetClassJava, exportedName, null); // api method to invoke 'otherm'
|
||||
if (apiMethod == null)
|
||||
{
|
||||
// logger.debug("Unable to find api method on {} with imported name {}, not injecting invoker", targetClassJava, exportedName);
|
||||
// logger.debug("Unable to find api method on {} with imported name {}, not injecting invoker", targetClassJava, exportedName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,17 +45,14 @@ import org.apache.maven.plugins.annotations.Parameter;
|
||||
)
|
||||
public class InjectMojo extends AbstractMojo
|
||||
{
|
||||
private final Log log = getLog();
|
||||
@Parameter(defaultValue = "${project.build.outputDirectory}")
|
||||
private File outputDirectory;
|
||||
|
||||
@Parameter(defaultValue = "./runescape-client/target/rs-client-${project.version}.jar", readonly = true, required = true)
|
||||
private String rsClientPath;
|
||||
|
||||
@Parameter(defaultValue = "${net.runelite.rs:vanilla:jar}", readonly = true, required = true)
|
||||
private String vanillaPath;
|
||||
|
||||
private final Log log = getLog();
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ public class InjectSetter
|
||||
private static final Logger logger = LoggerFactory.getLogger(InjectSetter.class);
|
||||
|
||||
private final Inject inject;
|
||||
|
||||
|
||||
private int injectedSetters;
|
||||
|
||||
public InjectSetter(Inject inject)
|
||||
@@ -61,12 +61,12 @@ public class InjectSetter
|
||||
/**
|
||||
* inject a setter into the vanilla classgroup
|
||||
*
|
||||
* @param targetClass Class where to inject the setter (field's class,
|
||||
* or client)
|
||||
* @param targetClass Class where to inject the setter (field's class,
|
||||
* or client)
|
||||
* @param targetApiClass API targetClass implements, which may have the
|
||||
* setter declared
|
||||
* @param field Field of vanilla that will be set
|
||||
* @param exportedName exported name of field
|
||||
* setter declared
|
||||
* @param field Field of vanilla that will be set
|
||||
* @param exportedName exported name of field
|
||||
* @param setter
|
||||
*/
|
||||
public void injectSetter(ClassFile targetClass, Class<?> targetApiClass, Field field, String exportedName, Number setter)
|
||||
@@ -114,7 +114,7 @@ public class InjectSetter
|
||||
// load argument
|
||||
Type argumentType = sig.getTypeOfArg(0);
|
||||
ins.add(inject.createLoadForTypeIndex(instructions, argumentType, 1));
|
||||
|
||||
|
||||
// cast argument to field type
|
||||
Type fieldType = field.getType();
|
||||
if (!argumentType.equals(fieldType))
|
||||
|
||||
@@ -39,17 +39,6 @@ public class Injector
|
||||
this.vanilla = vanilla;
|
||||
}
|
||||
|
||||
public void inject() throws InjectionException
|
||||
{
|
||||
Inject instance = new Inject(deobfuscated, vanilla);
|
||||
instance.run();
|
||||
}
|
||||
|
||||
public void save(File out) throws IOException
|
||||
{
|
||||
JarUtil.saveJar(vanilla, out);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, InjectionException
|
||||
{
|
||||
if (args.length < 3)
|
||||
@@ -72,5 +61,16 @@ public class Injector
|
||||
u.save(new File(args[2]));
|
||||
}
|
||||
|
||||
public void inject() throws InjectionException
|
||||
{
|
||||
Inject instance = new Inject(deobfuscated, vanilla);
|
||||
instance.run();
|
||||
}
|
||||
|
||||
public void save(File out) throws IOException
|
||||
{
|
||||
JarUtil.saveJar(vanilla, out);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ public class MixinInjector
|
||||
care of the garbage parameter itself.
|
||||
*/
|
||||
boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size()
|
||||
&& deobMethod.getDescriptor().size() < obMethodSignature.size();
|
||||
&& deobMethod.getDescriptor().size() < obMethodSignature.size();
|
||||
copiedMethods.put(method.getPoolMethod(), new CopiedMethod(copy, hasGarbageValue));
|
||||
|
||||
logger.debug("Injected copy of {} to {}", obMethod, copy);
|
||||
@@ -577,7 +577,7 @@ public class MixinInjector
|
||||
if (!returnType.equals(deobReturnType))
|
||||
{
|
||||
ClassFile deobReturnTypeClassFile = inject.getDeobfuscated()
|
||||
.findClass(deobReturnType.getInternalName());
|
||||
.findClass(deobReturnType.getInternalName());
|
||||
if (deobReturnTypeClassFile != null)
|
||||
{
|
||||
ClassFile obReturnTypeClass = inject.toObClass(deobReturnTypeClassFile);
|
||||
@@ -601,13 +601,13 @@ public class MixinInjector
|
||||
moveCode(obMethod, method.getCode());
|
||||
|
||||
boolean hasGarbageValue = method.getDescriptor().size() != obMethod.getDescriptor().size()
|
||||
&& deobMethod.getDescriptor().size() < obMethodSignature.size();
|
||||
&& deobMethod.getDescriptor().size() < obMethodSignature.size();
|
||||
|
||||
if (hasGarbageValue)
|
||||
{
|
||||
int garbageIndex = obMethod.isStatic()
|
||||
? obMethod.getDescriptor().size() - 1
|
||||
: obMethod.getDescriptor().size();
|
||||
? obMethod.getDescriptor().size() - 1
|
||||
: obMethod.getDescriptor().size();
|
||||
|
||||
/*
|
||||
If the mixin method doesn't have the garbage parameter,
|
||||
@@ -645,8 +645,8 @@ public class MixinInjector
|
||||
}
|
||||
|
||||
private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method,
|
||||
Map<net.runelite.asm.pool.Field, Field> shadowFields,
|
||||
Map<net.runelite.asm.pool.Method, CopiedMethod> copiedMethods)
|
||||
Map<net.runelite.asm.pool.Field, Field> shadowFields,
|
||||
Map<net.runelite.asm.pool.Method, CopiedMethod> copiedMethods)
|
||||
throws InjectionException
|
||||
{
|
||||
ListIterator<Instruction> iterator = method.getCode().getInstructions().getInstructions().listIterator();
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ClearColorBuffer
|
||||
if (current instanceof LDC && ((LDC) current).getConstantAsInt() == 0)
|
||||
{
|
||||
int varIdx = 0;
|
||||
for (; ;)
|
||||
for (; ; )
|
||||
{
|
||||
current = it.previous();
|
||||
if (current instanceof ILoad && ((ILoad) current).getVariableIndex() == 3 - varIdx)
|
||||
|
||||
@@ -166,7 +166,7 @@ public class DrawAfterWidgets
|
||||
{
|
||||
// If we get here, we're either in the wrong method
|
||||
// or Jagex has removed the "if (535573958 * kl != -1)"
|
||||
// logger.debug("Could not find the label for jumping to the " + noClip + " call in " + m);
|
||||
// logger.debug("Could not find the label for jumping to the " + noClip + " call in " + m);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user