asm: Use a more sensible approach for annotations
This commit is contained in:
@@ -27,16 +27,11 @@ package net.runelite.asm.annotations;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import net.runelite.asm.ClassFile;
|
||||
import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.asm.ClassUtil;
|
||||
import net.runelite.asm.Method;
|
||||
import net.runelite.asm.Type;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -62,20 +57,14 @@ public class AnnotationTest
|
||||
Method method = cf.getMethods().get(1);
|
||||
Assert.assertEquals("method1", method.getName());
|
||||
|
||||
Annotations annotations = method.getAnnotations();
|
||||
Assert.assertNotNull(annotations);
|
||||
var annotation = method.findAnnotation(new Type("Lnet/runelite/asm/annotations/MyAnnotation;"));
|
||||
Assert.assertNotNull(annotation);
|
||||
|
||||
Optional<Annotation> annotation = annotations.getAnnotations().stream().filter(a -> a.getType().equals(new Type("Lnet/runelite/asm/annotations/MyAnnotation;"))).findFirst();
|
||||
Assert.assertTrue(annotation.isPresent());
|
||||
Assert.assertEquals(1, annotation.size());
|
||||
|
||||
Annotation an = annotation.get();
|
||||
List<Element> elements = an.getElements();
|
||||
|
||||
Assert.assertEquals(1, elements.size());
|
||||
|
||||
Element element = elements.get(0);
|
||||
|
||||
Assert.assertEquals("value", element.getName());
|
||||
Assert.assertEquals("method1", element.getValue());
|
||||
Object element = annotation.getValue();
|
||||
Object also = annotation.get("value");
|
||||
Assert.assertEquals(also, element);
|
||||
Assert.assertEquals("method1", element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ public class MappingDumper
|
||||
for (ClassFile cf : group.getClasses())
|
||||
{
|
||||
String implName = cf.getName();
|
||||
String className = DeobAnnotations.getObfuscatedName(cf.getAnnotations());
|
||||
String className = DeobAnnotations.getObfuscatedName(cf);
|
||||
|
||||
if (implName != null)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ public class MappingDumper
|
||||
|
||||
for (Field f : cf.getFields())
|
||||
{
|
||||
String exportName = DeobAnnotations.getExportedName(f.getAnnotations());
|
||||
String exportName = DeobAnnotations.getExportedName(f);
|
||||
|
||||
if (exportName == null)
|
||||
{
|
||||
@@ -101,7 +101,7 @@ public class MappingDumper
|
||||
|
||||
++fields;
|
||||
|
||||
String fieldName = DeobAnnotations.getObfuscatedName(f.getAnnotations());
|
||||
String fieldName = DeobAnnotations.getObfuscatedName(f);
|
||||
Type type = f.getType();
|
||||
Number getter = DeobAnnotations.getObfuscatedGetter(f);
|
||||
|
||||
@@ -171,7 +171,7 @@ public class MappingDumper
|
||||
|
||||
for (Method m : cf.getMethods())
|
||||
{
|
||||
String exportName = DeobAnnotations.getExportedName(m.getAnnotations());
|
||||
String exportName = DeobAnnotations.getExportedName(m);
|
||||
|
||||
if (exportName == null)
|
||||
{
|
||||
@@ -180,7 +180,7 @@ public class MappingDumper
|
||||
|
||||
methods++;
|
||||
|
||||
String methodName = DeobAnnotations.getObfuscatedName(m.getAnnotations());
|
||||
String methodName = DeobAnnotations.getObfuscatedName(m);
|
||||
Signature signature = DeobAnnotations.getObfuscatedSignature(m);
|
||||
String garbageValue = DeobAnnotations.getDecoder(m);
|
||||
|
||||
@@ -329,18 +329,18 @@ public class MappingDumper
|
||||
for (ClassFile cf : group.getClasses())
|
||||
{
|
||||
String implName = DeobAnnotations.getImplements(cf);
|
||||
String className = DeobAnnotations.getObfuscatedName(cf.getAnnotations());
|
||||
String className = DeobAnnotations.getObfuscatedName(cf);
|
||||
|
||||
for (Field f : cf.getFields())
|
||||
{
|
||||
String exportName = DeobAnnotations.getExportedName(f.getAnnotations());
|
||||
String exportName = DeobAnnotations.getExportedName(f);
|
||||
|
||||
if (exportName == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String fieldName = DeobAnnotations.getObfuscatedName(f.getAnnotations());
|
||||
String fieldName = DeobAnnotations.getObfuscatedName(f);
|
||||
Type obfType = DeobAnnotations.getObfuscatedType(f);
|
||||
Number getter = DeobAnnotations.getObfuscatedGetter(f);
|
||||
|
||||
@@ -361,14 +361,14 @@ public class MappingDumper
|
||||
for (Method m : cf.getMethods())
|
||||
{
|
||||
|
||||
String exportName = DeobAnnotations.getExportedName(m.getAnnotations());
|
||||
String exportName = DeobAnnotations.getExportedName(m);
|
||||
|
||||
if (exportName == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String methodName = DeobAnnotations.getObfuscatedName(m.getAnnotations());
|
||||
String methodName = DeobAnnotations.getObfuscatedName(m);
|
||||
Signature obfSignature = DeobAnnotations.getObfuscatedSignature(m);
|
||||
String predicate = DeobAnnotations.getDecoder(m);
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import net.runelite.asm.ClassFile;
|
||||
import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.asm.Field;
|
||||
import net.runelite.asm.Method;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.deob.Deob;
|
||||
import net.runelite.deob.DeobAnnotations;
|
||||
import net.runelite.deob.DeobTestProperties;
|
||||
@@ -58,14 +57,12 @@ public class AnnotationCleaner
|
||||
|
||||
for (Field f : c.getFields())
|
||||
{
|
||||
Annotations an = f.getAnnotations();
|
||||
|
||||
String fieldName = f.getName();
|
||||
String exportedName = DeobAnnotations.getExportedName(an);
|
||||
String exportedName = DeobAnnotations.getExportedName(f);
|
||||
|
||||
if (exportedName == null)
|
||||
{
|
||||
if (!Deob.isObfuscated(fieldName) && DeobAnnotations.getObfuscatedName(an) != null)
|
||||
if (!Deob.isObfuscated(fieldName) && DeobAnnotations.getObfuscatedName(f) != null)
|
||||
{
|
||||
missing.add("Export: (field) " + className + '.' + fieldName + " == missing");
|
||||
}
|
||||
@@ -78,14 +75,12 @@ public class AnnotationCleaner
|
||||
|
||||
for (Method m : c.getMethods())
|
||||
{
|
||||
Annotations an = m.getAnnotations();
|
||||
|
||||
String methodName = m.getName();
|
||||
String exportedName = DeobAnnotations.getExportedName(an);
|
||||
String exportedName = DeobAnnotations.getExportedName(m);
|
||||
|
||||
if (exportedName == null)
|
||||
{
|
||||
if (!Deob.isObfuscated(methodName) && DeobAnnotations.getObfuscatedName(an) != null)
|
||||
if (!Deob.isObfuscated(methodName) && DeobAnnotations.getObfuscatedName(m) != null)
|
||||
{
|
||||
missing.add("Export: (method) " + className + '.' + methodName + " == missing");
|
||||
}
|
||||
@@ -124,7 +119,7 @@ public class AnnotationCleaner
|
||||
JarUtil.saveJar(group, new File("C:/Users/Lucas/Desktop/niec.jar"));
|
||||
}
|
||||
|
||||
private class OhNoException extends Exception
|
||||
private static class OhNoException extends Exception
|
||||
{
|
||||
private OhNoException()
|
||||
{
|
||||
|
||||
@@ -105,16 +105,16 @@ public class UpdateMappingsTest
|
||||
{
|
||||
for (ClassFile cf : group.getClasses())
|
||||
{
|
||||
cf.getAnnotations().clearAnnotations();
|
||||
cf.getAnnotations().clear();
|
||||
|
||||
for (Field f : cf.getFields())
|
||||
{
|
||||
f.getAnnotations().clearAnnotations();
|
||||
f.getAnnotations().clear();
|
||||
}
|
||||
|
||||
for (Method m : cf.getMethods())
|
||||
{
|
||||
m.getAnnotations().clearAnnotations();
|
||||
m.getAnnotations().clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,8 +136,8 @@ public class UpdateMappingsTest
|
||||
|
||||
assert otherf != null : "unable to find " + f;
|
||||
|
||||
String name = DeobAnnotations.getExportedName(f.getAnnotations());
|
||||
String otherName = DeobAnnotations.getExportedName(otherf.getAnnotations());
|
||||
String name = DeobAnnotations.getExportedName(f);
|
||||
String otherName = DeobAnnotations.getExportedName(otherf);
|
||||
|
||||
Assert.assertEquals(name + " <-> " + otherName, name, otherName);
|
||||
}
|
||||
@@ -148,8 +148,8 @@ public class UpdateMappingsTest
|
||||
|
||||
assert otherm != null : "unable to find " + m;
|
||||
|
||||
String name = DeobAnnotations.getExportedName(m.getAnnotations());
|
||||
String otherName = DeobAnnotations.getExportedName(otherm.getAnnotations());
|
||||
String name = DeobAnnotations.getExportedName(m);
|
||||
String otherName = DeobAnnotations.getExportedName(otherm);
|
||||
|
||||
Assert.assertEquals(name + " <-> " + otherName, name, otherName);
|
||||
}
|
||||
|
||||
@@ -36,10 +36,9 @@ import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.asm.Field;
|
||||
import net.runelite.asm.Method;
|
||||
import net.runelite.asm.Type;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.attributes.Annotated;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
import net.runelite.deob.DeobAnnotations;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import net.runelite.osb.inject.ClassHook;
|
||||
import net.runelite.osb.inject.FieldHook;
|
||||
@@ -88,17 +87,17 @@ public class HookImporter
|
||||
{
|
||||
int classes = 0, fields = 0, methods = 0, callbacks = 0;
|
||||
|
||||
for (String deobfuscatedClassName : hooks.keySet())
|
||||
for (Map.Entry<String, ClassHook> entry : hooks.entrySet())
|
||||
{
|
||||
ClassHook ch = hooks.get(deobfuscatedClassName);
|
||||
ClassHook ch = entry.getValue();
|
||||
ClassFile cf = this.findClassWithObfuscatedName(ch.getClazz());
|
||||
|
||||
assert cf != null;
|
||||
|
||||
String implementsName = getAnnotation(cf.getAnnotations(), IMPLEMENTS);
|
||||
String implementsName = getAnnotation(cf, IMPLEMENTS);
|
||||
if (implementsName.isEmpty())
|
||||
{
|
||||
cf.getAnnotations().addAnnotation(IMPLEMENTS, "value", deobfuscatedClassName);
|
||||
cf.addAnnotation(IMPLEMENTS, entry.getKey());
|
||||
++classes;
|
||||
}
|
||||
|
||||
@@ -127,10 +126,10 @@ public class HookImporter
|
||||
|
||||
assert f != null;
|
||||
|
||||
String exportedName = getAnnotation(f.getAnnotations(), EXPORT);
|
||||
String exportedName = getAnnotation(f, EXPORT);
|
||||
if (exportedName.isEmpty())
|
||||
{
|
||||
f.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedFieldName);
|
||||
f.addAnnotation(EXPORT, deobfuscatedFieldName);
|
||||
++fields;
|
||||
}
|
||||
}
|
||||
@@ -160,10 +159,10 @@ public class HookImporter
|
||||
|
||||
assert m != null;
|
||||
|
||||
String exportedName = getAnnotation(m.getAnnotations(), EXPORT);
|
||||
String exportedName = getAnnotation(m, EXPORT);
|
||||
if (exportedName.isEmpty())
|
||||
{
|
||||
m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName);
|
||||
m.addAnnotation(EXPORT, deobfuscatedMethodName);
|
||||
++methods;
|
||||
}
|
||||
}
|
||||
@@ -193,10 +192,10 @@ public class HookImporter
|
||||
|
||||
assert m != null;
|
||||
|
||||
String exportedName = getAnnotation(m.getAnnotations(), EXPORT);
|
||||
String exportedName = getAnnotation(m, EXPORT);
|
||||
if (exportedName.isEmpty())
|
||||
{
|
||||
m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName);
|
||||
m.addAnnotation(EXPORT, deobfuscatedMethodName);
|
||||
++callbacks;
|
||||
}
|
||||
}
|
||||
@@ -214,8 +213,7 @@ public class HookImporter
|
||||
return c;
|
||||
}
|
||||
|
||||
Annotations an = c.getAnnotations();
|
||||
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
|
||||
if (getAnnotation(c, OBFUSCATED_NAME).equals(name))
|
||||
{
|
||||
return c;
|
||||
}
|
||||
@@ -227,8 +225,7 @@ public class HookImporter
|
||||
{
|
||||
for (Field f : c.getFields())
|
||||
{
|
||||
Annotations an = f.getAnnotations();
|
||||
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
|
||||
if (name.equals(DeobAnnotations.getObfuscatedName(f)))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
@@ -242,8 +239,7 @@ public class HookImporter
|
||||
|
||||
for (Method m : c.getMethods())
|
||||
{
|
||||
Annotations an = m.getAnnotations();
|
||||
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
|
||||
if (getAnnotation(m, OBFUSCATED_NAME).equals(name))
|
||||
{
|
||||
Signature methodSig = getObfuscatedMethodSignature(m);
|
||||
|
||||
@@ -261,30 +257,15 @@ public class HookImporter
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getAnnotation(Annotations an, Type type)
|
||||
private String getAnnotation(Annotated an, Type type)
|
||||
{
|
||||
if (an == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
for (Annotation a : an.getAnnotations())
|
||||
{
|
||||
if (a.getType().equals(type))
|
||||
{
|
||||
for (Element e : a.getElements())
|
||||
{
|
||||
return (String) e.getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
final var s = DeobAnnotations.getStringValue(an, type);
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
private Signature getObfuscatedMethodSignature(Method method)
|
||||
{
|
||||
String sig = getAnnotation(method.getAnnotations(), OBFUSCATED_SIGNATURE);
|
||||
String sig = getAnnotation(method, OBFUSCATED_SIGNATURE);
|
||||
if (!sig.isEmpty())
|
||||
{
|
||||
return toObSignature(new Signature(sig)); // if it is annoted, use that
|
||||
@@ -310,8 +291,7 @@ public class HookImporter
|
||||
ClassFile cf = group.findClass(t.getInternalName());
|
||||
assert cf != null;
|
||||
|
||||
Annotations an = cf.getAnnotations();
|
||||
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
|
||||
String obfuscatedName = (String) cf.findAnnotation(OBFUSCATED_NAME).getValue();
|
||||
return Type.getType("L" + obfuscatedName + ";", t.getDimensions());
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ import net.runelite.asm.ClassFile;
|
||||
import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.asm.Field;
|
||||
import net.runelite.asm.Type;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.Annotation;
|
||||
import net.runelite.asm.attributes.Annotated;
|
||||
import net.runelite.deob.DeobAnnotations;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import net.runelite.runeloader.inject.AddInterfaceInstruction;
|
||||
import net.runelite.runeloader.inject.GetterInjectInstruction;
|
||||
@@ -73,29 +73,13 @@ public class MappingImporter
|
||||
JarUtil.saveJar(group, OUT);
|
||||
}
|
||||
|
||||
private boolean hasObfuscatedName(Annotations an, String name)
|
||||
private boolean hasObfuscatedName(Annotated an, String name)
|
||||
{
|
||||
if (an == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Annotation a : an.getAnnotations())
|
||||
{
|
||||
if (a.getType().equals(OBFUSCATED_NAME))
|
||||
{
|
||||
for (Element e : a.getElements())
|
||||
{
|
||||
String str = (String) e.getValue();
|
||||
if (str.equals(name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return name.equals(DeobAnnotations.getStringValue(an, OBFUSCATED_NAME));
|
||||
}
|
||||
|
||||
private ClassFile findClassWithObfuscatedName(String name)
|
||||
@@ -107,8 +91,7 @@ public class MappingImporter
|
||||
return c;
|
||||
}
|
||||
|
||||
Annotations an = c.getAnnotations();
|
||||
if (this.hasObfuscatedName(an, name))
|
||||
if (this.hasObfuscatedName(c, name))
|
||||
{
|
||||
return c;
|
||||
}
|
||||
@@ -120,8 +103,7 @@ public class MappingImporter
|
||||
{
|
||||
for (Field f : c.getFields())
|
||||
{
|
||||
Annotations an = f.getAnnotations();
|
||||
if (this.hasObfuscatedName(an, name))
|
||||
if (this.hasObfuscatedName(f, name))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
@@ -131,7 +113,7 @@ public class MappingImporter
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void makeMappings() throws IOException
|
||||
public void makeMappings()
|
||||
{
|
||||
InjectionModscript mod = Injection.load(MappingImporter.class.getResourceAsStream(RL_INJECTION));
|
||||
int fields = 0, classes = 0;
|
||||
@@ -154,12 +136,10 @@ public class MappingImporter
|
||||
String attrName = gii.getGetterName();
|
||||
attrName = Utils.toExportedName(attrName);
|
||||
|
||||
Annotations an = f.getAnnotations();
|
||||
|
||||
Annotation a = an.find(EXPORT);
|
||||
Annotation a = f.findAnnotation(EXPORT);
|
||||
if (a != null)
|
||||
{
|
||||
String exportedName = a.getElement().getString();
|
||||
String exportedName = a.getValueString();
|
||||
|
||||
if (!attrName.equals(exportedName))
|
||||
{
|
||||
@@ -168,7 +148,7 @@ public class MappingImporter
|
||||
}
|
||||
else
|
||||
{
|
||||
an.addAnnotation(EXPORT, "value", attrName);
|
||||
f.addAnnotation(EXPORT, attrName);
|
||||
|
||||
logger.info("Exporting field " + f + " with name " + attrName);
|
||||
++fields;
|
||||
@@ -184,12 +164,10 @@ public class MappingImporter
|
||||
|
||||
iface = iface.replace("com/runeloader/api/bridge/os/accessor/", "");
|
||||
|
||||
Annotations an = cf.getAnnotations();
|
||||
|
||||
Annotation a = an.find(IMPLEMENTS);
|
||||
Annotation a = cf.findAnnotation(IMPLEMENTS);
|
||||
if (a != null)
|
||||
{
|
||||
String implementsName = a.getElement().getString();
|
||||
String implementsName = a.getValueString();
|
||||
|
||||
if (!iface.equals(implementsName))
|
||||
{
|
||||
@@ -198,7 +176,7 @@ public class MappingImporter
|
||||
}
|
||||
else
|
||||
{
|
||||
an.addAnnotation(IMPLEMENTS, "value", iface);
|
||||
cf.addAnnotation(IMPLEMENTS, iface);
|
||||
|
||||
logger.info("Exporting class " + cf.getName() + " with name " + iface);
|
||||
++classes;
|
||||
|
||||
@@ -36,9 +36,7 @@ import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.asm.Field;
|
||||
import net.runelite.asm.Method;
|
||||
import net.runelite.asm.Type;
|
||||
import net.runelite.asm.attributes.Annotations;
|
||||
import net.runelite.asm.attributes.annotation.Annotation;
|
||||
import net.runelite.asm.attributes.annotation.Element;
|
||||
import net.runelite.asm.attributes.Annotated;
|
||||
import net.runelite.asm.attributes.code.LocalVariable;
|
||||
import net.runelite.asm.attributes.code.Parameter;
|
||||
import net.runelite.asm.signature.Signature;
|
||||
@@ -107,11 +105,11 @@ public class HookImporter
|
||||
|
||||
assert cf != null;
|
||||
|
||||
String implementsName = getAnnotation(cf.getAnnotations(), IMPLEMENTS);
|
||||
String implementsName = getAnnotation(cf, IMPLEMENTS);
|
||||
if (implementsName.isEmpty())
|
||||
{
|
||||
String deobfuscatedClassName = hc.clazz;
|
||||
cf.getAnnotations().addAnnotation(IMPLEMENTS, "value", deobfuscatedClassName);
|
||||
cf.addAnnotation(IMPLEMENTS, deobfuscatedClassName);
|
||||
mappings.map(cf.getPoolClass(), deobfuscatedClassName);
|
||||
++classes;
|
||||
}
|
||||
@@ -138,7 +136,7 @@ public class HookImporter
|
||||
continue;
|
||||
}
|
||||
|
||||
String exportedName = getAnnotation(f.getAnnotations(), EXPORT);
|
||||
String exportedName = getAnnotation(f, EXPORT);
|
||||
if (exportedName.isEmpty())
|
||||
{
|
||||
String deobfuscatedFieldName = fh.field;
|
||||
@@ -150,7 +148,7 @@ public class HookImporter
|
||||
continue;
|
||||
}
|
||||
|
||||
f.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedFieldName);
|
||||
f.addAnnotation(EXPORT, deobfuscatedFieldName);
|
||||
mappings.map(f.getPoolField(), deobfuscatedFieldName);
|
||||
++fields;
|
||||
}
|
||||
@@ -219,7 +217,7 @@ public class HookImporter
|
||||
List<Method> virtualMethods = VirtualMethods.getVirtualMethods(m);
|
||||
for (Method method : virtualMethods)
|
||||
{
|
||||
String exportedName = getAnnotation(method.getAnnotations(), EXPORT);
|
||||
String exportedName = getAnnotation(method, EXPORT);
|
||||
if (!exportedName.isEmpty())
|
||||
{
|
||||
if (!exportedName.equals(hm.method))
|
||||
@@ -231,7 +229,7 @@ public class HookImporter
|
||||
}
|
||||
|
||||
String deobfuscatedMethodName = hm.method;
|
||||
m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName);
|
||||
m.addAnnotation(EXPORT, deobfuscatedMethodName);
|
||||
mappings.map(m.getPoolMethod(), deobfuscatedMethodName);
|
||||
++methods;
|
||||
}
|
||||
@@ -252,8 +250,7 @@ public class HookImporter
|
||||
return c;
|
||||
}
|
||||
|
||||
Annotations an = c.getAnnotations();
|
||||
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
|
||||
if (getAnnotation(c, OBFUSCATED_NAME).equals(name))
|
||||
{
|
||||
return c;
|
||||
}
|
||||
@@ -265,8 +262,7 @@ public class HookImporter
|
||||
{
|
||||
for (Field f : c.getFields())
|
||||
{
|
||||
Annotations an = f.getAnnotations();
|
||||
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
|
||||
if (getAnnotation(f, OBFUSCATED_NAME).equals(name))
|
||||
{
|
||||
return f;
|
||||
}
|
||||
@@ -280,8 +276,7 @@ public class HookImporter
|
||||
|
||||
for (Method m : c.getMethods())
|
||||
{
|
||||
Annotations an = m.getAnnotations();
|
||||
if (m.getName().equals(name) || getAnnotation(an, OBFUSCATED_NAME).equals(name))
|
||||
if (m.getName().equals(name) || getAnnotation(m, OBFUSCATED_NAME).equals(name))
|
||||
{
|
||||
Signature methodSig = getObfuscatedMethodSignature(m);
|
||||
|
||||
@@ -294,15 +289,12 @@ public class HookImporter
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getAnnotation(Annotations an, Type type)
|
||||
private String getAnnotation(Annotated an, Type type)
|
||||
{
|
||||
Annotation a = an.find(type);
|
||||
final var a = an.findAnnotation(type);
|
||||
if (a != null)
|
||||
{
|
||||
for (Element e : a.getElements())
|
||||
{
|
||||
return (String) e.getValue();
|
||||
}
|
||||
return a.getValueString();
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -310,7 +302,7 @@ public class HookImporter
|
||||
|
||||
private Signature getObfuscatedMethodSignature(Method method)
|
||||
{
|
||||
String sig = getAnnotation(method.getAnnotations(), OBFUSCATED_SIGNATURE);
|
||||
String sig = getAnnotation(method, OBFUSCATED_SIGNATURE);
|
||||
if (sig.isEmpty())
|
||||
{
|
||||
return method.getDescriptor();
|
||||
|
||||
Reference in New Issue
Block a user