Realized I can also use mapping importer to check mappings. This finds some discrepancies with the update RL mappings, but on manual inspection the RL mappings seem wrong.
This commit is contained in:
@@ -11,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.runelite.deob.runeloader.inject.GetterInjectInstruction;
|
||||
import net.runelite.deob.runeloader.inject.InjectionModscript;
|
||||
import net.runelite.mapping.Export;
|
||||
import net.runelite.mapping.ObfuscatedGetter;
|
||||
import net.runelite.mapping.ObfuscatedName;
|
||||
import org.junit.Assert;
|
||||
@@ -19,8 +20,8 @@ import org.junit.Test;
|
||||
|
||||
public class CheckMappings
|
||||
{
|
||||
private static final File CLIENT = new File("/Users/adam/w/rs/07/rs-client-1.0-SNAPSHOT.jar");
|
||||
private static final File RL_INJECTION = new File("/Users/adam/w/rs/07/rl/injection.json");
|
||||
private static final File CLIENT = new File("d:/rs/07/adamout.jar");
|
||||
private static final File RL_INJECTION = new File(CheckMappings.class.getResource("/injection_v18.json").getFile());
|
||||
|
||||
private final List<Class> classes = new ArrayList<>();
|
||||
|
||||
@@ -29,14 +30,14 @@ public class CheckMappings
|
||||
{
|
||||
ClassLoader loader = new URLClassLoader(new URL[] { CLIENT.toURL() });
|
||||
|
||||
Class c = loader.loadClass("net.runelite.rs.client.client");
|
||||
Class c = loader.loadClass("client");
|
||||
classes.add(c);
|
||||
|
||||
for (int i = 0; i < 230; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
c = loader.loadClass("net.runelite.rs.client.class" + i);
|
||||
c = loader.loadClass("class" + i);
|
||||
classes.add(c);
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
@@ -81,7 +82,15 @@ public class CheckMappings
|
||||
ObfuscatedGetter getter = (ObfuscatedGetter) f.getDeclaredAnnotation(ObfuscatedGetter.class);
|
||||
if (getter == null)
|
||||
return null;
|
||||
return getter.intValue();
|
||||
return getter.intValue() == 0 ? null : getter.intValue();
|
||||
}
|
||||
|
||||
private String getExportedName(Field f)
|
||||
{
|
||||
Export e = (Export) f.getDeclaredAnnotation(Export.class);
|
||||
if (e == null)
|
||||
return null;
|
||||
return e.value();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,14 +107,18 @@ public class CheckMappings
|
||||
|
||||
Field f = this.findFieldWithObfuscatedName(c, gii.getGetterFieldName());
|
||||
Assert.assertNotNull(f);
|
||||
|
||||
String exportedName = this.getExportedName(f);
|
||||
String attrName = gii.getGetterName();
|
||||
attrName = Utils.toExportedName(attrName);
|
||||
|
||||
Integer mul = gii.getMultiplier(),
|
||||
myMul = this.getIntegerMultiplier(f);
|
||||
|
||||
if (myMul != null && myMul == 0)
|
||||
myMul = null;
|
||||
|
||||
Assert.assertTrue(Objects.equal(mul, myMul));
|
||||
|
||||
// XXX Check @Export etc names
|
||||
|
||||
//Assert.assertEquals(exportedName, attrName);
|
||||
Assert.assertEquals(myMul, mul);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,12 @@ package net.runelite.deob.runeloader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import net.runelite.deob.ClassFile;
|
||||
import net.runelite.deob.ClassGroup;
|
||||
import net.runelite.deob.Field;
|
||||
import net.runelite.deob.Interfaces;
|
||||
import net.runelite.deob.attributes.Annotations;
|
||||
import net.runelite.deob.attributes.AttributeType;
|
||||
import net.runelite.deob.attributes.Attributes;
|
||||
import net.runelite.deob.attributes.annotation.Annotation;
|
||||
import net.runelite.deob.attributes.annotation.Element;
|
||||
import net.runelite.deob.pool.UTF8;
|
||||
@@ -24,9 +23,9 @@ import org.junit.Test;
|
||||
|
||||
public class MappingImporter
|
||||
{
|
||||
private static final File IN = new File("d:/rs/07/adamin.jar");
|
||||
private static final File IN = new File("d:/rs/07/gamepack_v18_annotationmap.jar");
|
||||
private static final File OUT = new File("d:/rs/07/adamout.jar");
|
||||
private static final File RL_INJECTION = new File(MappingImporter.class.getResource("/injection_v16.json").getFile());
|
||||
private static final File RL_INJECTION = new File(MappingImporter.class.getResource("/injection_v18.json").getFile());
|
||||
|
||||
private static final Type OBFUSCATED_NAME = new Type("Lnet/runelite/mapping/ObfuscatedName;");
|
||||
private static final Type EXPORT = new Type("Lnet/runelite/mapping/Export;");
|
||||
@@ -112,13 +111,25 @@ public class MappingImporter
|
||||
Assert.assertNotNull(f);
|
||||
|
||||
String attrName = gii.getGetterName();
|
||||
if (attrName.startsWith("get"))
|
||||
attrName = Utils.toExportedName(attrName);
|
||||
|
||||
Attributes attr = f.getAttributes();
|
||||
Annotations an = attr.getAnnotations();
|
||||
|
||||
Annotation a = an.find(EXPORT);
|
||||
if (a != null)
|
||||
{
|
||||
attrName = attrName.substring(3);
|
||||
attrName = Character.toLowerCase(attrName.charAt(0)) + attrName.substring(1);
|
||||
String exportedName = a.getElement().getString();
|
||||
|
||||
if (!attrName.equals(exportedName))
|
||||
{
|
||||
System.out.println("Exported field " + f + " with mismatched name. Theirs: " + attrName + ", mine: " + exportedName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
attr.addAnnotation(EXPORT, "value", new UTF8(attrName));
|
||||
}
|
||||
|
||||
f.getAttributes().addAnnotation(EXPORT, "value", new UTF8(attrName));
|
||||
}
|
||||
|
||||
for (AddInterfaceInstruction aii : mod.getAddInterfaceInjects())
|
||||
@@ -129,8 +140,24 @@ public class MappingImporter
|
||||
String iface = aii.getInterfaceClass();
|
||||
|
||||
iface = iface.replace("com/runeloader/api/bridge/os/accessor/", "");
|
||||
|
||||
cf.getAttributes().addAnnotation(IMPLEMENTS, "value", new UTF8(iface));
|
||||
|
||||
Attributes attr = cf.getAttributes();
|
||||
Annotations an = attr.getAnnotations();
|
||||
|
||||
Annotation a = an.find(IMPLEMENTS);
|
||||
if (a != null)
|
||||
{
|
||||
String implementsName = a.getElement().getString();
|
||||
|
||||
if (!iface.equals(implementsName))
|
||||
{
|
||||
System.out.println("Implements class " + cf + " with mismatched name. Theirs: " + iface + ", mine: " + implementsName);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
attr.addAnnotation(IMPLEMENTS, "value", new UTF8(iface));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
18
src/test/java/net/runelite/deob/runeloader/Utils.java
Normal file
18
src/test/java/net/runelite/deob/runeloader/Utils.java
Normal file
@@ -0,0 +1,18 @@
|
||||
package net.runelite.deob.runeloader;
|
||||
|
||||
public class Utils
|
||||
{
|
||||
public static String toExportedName(String attrName)
|
||||
{
|
||||
if (attrName.startsWith("get"))
|
||||
{
|
||||
attrName = attrName.substring(3);
|
||||
attrName = Character.toLowerCase(attrName.charAt(0)) + attrName.substring(1);
|
||||
}
|
||||
|
||||
if (attrName.equalsIgnoreCase("fps"))
|
||||
attrName = "FPS";
|
||||
|
||||
return attrName;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,12 @@ public class GetterInjectInstruction {
|
||||
this.staticField = var7;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "GetterInjectInstruction{" + "className=" + className + ", getterMethodDesc=" + getterMethodDesc + ", getterName=" + getterName + ", getterClassName=" + getterClassName + ", getterFieldName=" + getterFieldName + ", multiplier=" + multiplier + ", staticField=" + staticField + '}';
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return this.className;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user