diff --git a/src/test/java/net/runelite/deob/runeloader/CheckMappings.java b/src/test/java/net/runelite/deob/runeloader/CheckMappings.java index bba94f75e2..8298f3ec8a 100644 --- a/src/test/java/net/runelite/deob/runeloader/CheckMappings.java +++ b/src/test/java/net/runelite/deob/runeloader/CheckMappings.java @@ -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 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); } } } diff --git a/src/test/java/net/runelite/deob/runeloader/MappingImporter.java b/src/test/java/net/runelite/deob/runeloader/MappingImporter.java index 1e73aa884b..2c8c257b7c 100644 --- a/src/test/java/net/runelite/deob/runeloader/MappingImporter.java +++ b/src/test/java/net/runelite/deob/runeloader/MappingImporter.java @@ -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)); + } } } } diff --git a/src/test/java/net/runelite/deob/runeloader/Utils.java b/src/test/java/net/runelite/deob/runeloader/Utils.java new file mode 100644 index 0000000000..b367fca114 --- /dev/null +++ b/src/test/java/net/runelite/deob/runeloader/Utils.java @@ -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; + } +} diff --git a/src/test/java/net/runelite/deob/runeloader/inject/GetterInjectInstruction.java b/src/test/java/net/runelite/deob/runeloader/inject/GetterInjectInstruction.java index 413b6b008b..06cbfcbb70 100644 --- a/src/test/java/net/runelite/deob/runeloader/inject/GetterInjectInstruction.java +++ b/src/test/java/net/runelite/deob/runeloader/inject/GetterInjectInstruction.java @@ -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; }