Import bugfixes. Need to @Import annotations etc since it can't pick up methods from the api atm

This commit is contained in:
Adam
2016-03-05 23:34:47 -05:00
parent 2675a402e4
commit bb81dcf260
3 changed files with 46 additions and 9 deletions

View File

@@ -61,11 +61,14 @@ public class Inject
private Type toObType(Type t)
{
if (t.isPrimitive())
return t;
String className = t.getType();
ClassFile cf = deobfuscated.findClass(className);
Annotations an = cf.getAttributes().getAnnotations();
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
return new Type(obfuscatedName, t.getArrayDims());
}
@@ -83,7 +86,11 @@ public class Inject
for (ClassFile cf : deobfuscated.getClasses())
{
Annotations an = cf.getAttributes().getAnnotations();
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
String obfuscatedName = cf.getName();
Annotation obfuscatedNameAnnotation = an.find(OBFUSCATED_NAME);
if (obfuscatedNameAnnotation != null)
obfuscatedName = obfuscatedNameAnnotation.getElement().getString();
ClassFile other = vanilla.findClass(obfuscatedName);
assert other != null;
@@ -99,8 +106,8 @@ public class Inject
if (an.find(EXPORT) == null)
continue; // not an exported field
String exportedName = an.find(EXPORT).getElement().toString();
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
String exportedName = an.find(EXPORT).getElement().getString();
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
Annotation getterAnnotation = an.find(OBFUSCATED_GETTER);
Number getter = null;
@@ -131,8 +138,8 @@ public class Inject
if (an.find(EXPORT) == null)
continue; // not an exported method
String exportedName = an.find(EXPORT).getElement().toString();
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().toString();
String exportedName = an.find(EXPORT).getElement().getString();
obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
// XXX static methods don't have to be in the same class, so we should have @ObfuscatedClass or something
@@ -152,7 +159,7 @@ public class Inject
if (a == null)
return null;
String ifaceName = a.getElement().toString();
String ifaceName = "net.runelite.rs.api." + a.getElement().getString();
Class clazz = new Class(ifaceName);
Interfaces interfaces = other.getInterfaces();
@@ -164,7 +171,7 @@ public class Inject
}
catch (ClassNotFoundException ex)
{
ex.addSuppressed(ex);
ex.printStackTrace();
return null;
}
}

View File

@@ -0,0 +1,30 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package net.runelite.deob.injection;
import java.io.File;
import java.io.IOException;
import net.runelite.deob.ClassGroup;
import net.runelite.deob.runeloader.MappingImporter;
import net.runelite.deob.util.JarUtil;
import org.junit.Test;
public class InjectTest
{
private static final File DEOBFUSCATED = new File("d:/rs/07/adamin.jar");
private static final File VANILLA = new File(MappingImporter.class.getResource("/gamepack_v16.jar").getFile());
@Test
public void testRun() throws IOException
{
ClassGroup deob = JarUtil.loadJar(DEOBFUSCATED),
vanilla = JarUtil.loadJar(VANILLA);
Inject instance = new Inject(deob, vanilla);
instance.run();
}
}

View File

@@ -26,7 +26,7 @@ public class MappingImporter
{
private static final File IN = new File("d:/rs/07/adamin.jar");
private static final File OUT = new File("d:/rs/07/adamout.jar");
private static final File RL_INJECTION = new File("C:\\Users\\Adam\\git\\jbytecode\\src\\test\\resources\\injection_v16.json");
private static final File RL_INJECTION = new File(MappingImporter.class.getResource("/injection_v16.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;");