injector: loadJar -> load, small cleanups in main

This commit is contained in:
TheRealNull
2021-01-02 04:16:57 -05:00
parent 099f89f1d0
commit cdd293a865
33 changed files with 64 additions and 68 deletions

View File

@@ -77,7 +77,7 @@ public class Deob
Stopwatch stopwatch = Stopwatch.createStarted(); Stopwatch stopwatch = Stopwatch.createStarted();
ClassGroup group = JarUtil.loadJar(new File(args[0])); ClassGroup group = JarUtil.load(new File(args[0]));
// remove except RuntimeException // remove except RuntimeException
run(group, new RuntimeExceptions()); run(group, new RuntimeExceptions());

View File

@@ -93,8 +93,8 @@ public class UpdateMappings
} }
UpdateMappings u = new UpdateMappings( UpdateMappings u = new UpdateMappings(
JarUtil.loadJar(new File(args[0])), JarUtil.load(new File(args[0])),
JarUtil.loadJar(new File(args[1])) JarUtil.load(new File(args[1]))
); );
u.update(); u.update();
u.save(new File(args[2])); u.save(new File(args[2]));

View File

@@ -49,7 +49,7 @@ public class JarUtil
{ {
private static final Logger logger = LoggerFactory.getLogger(JarUtil.class); private static final Logger logger = LoggerFactory.getLogger(JarUtil.class);
public static ClassGroup loadJar(File jarfile) throws IOException public static ClassGroup load(File jarfile)
{ {
ClassGroup group = new ClassGroup(); ClassGroup group = new ClassGroup();
@@ -74,6 +74,10 @@ public class JarUtil
group.addClass(cv.getClassFile()); group.addClass(cv.getClassFile());
} }
} }
catch (IOException e)
{
e.printStackTrace();
}
group.initialize(); group.initialize();

View File

@@ -39,7 +39,7 @@ public class ExecutionTest
@Test @Test
public void test() throws Exception public void test() throws Exception
{ {
ClassGroup group1 = JarUtil.loadJar(new File(properties.getVanillaClient())); ClassGroup group1 = JarUtil.load(new File(properties.getVanillaClient()));
Execution e = new Execution(group1); Execution e = new Execution(group1);
e.populateInitialMethods(); e.populateInitialMethods();
e.run(); e.run();

View File

@@ -45,7 +45,7 @@ public class ClassFileVisitorTest
@Test @Test
public void test() throws Exception public void test() throws Exception
{ {
ClassGroup group = JarUtil.loadJar(new File(properties.getVanillaClient())); ClassGroup group = JarUtil.load(new File(properties.getVanillaClient()));
JarUtil.saveJar(group, folder.newFile()); JarUtil.saveJar(group, folder.newFile());
} }

View File

@@ -50,7 +50,7 @@ public class EnumDeobfuscatorTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class FieldInlinerTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class IllegalStateExceptionsTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class OrderTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class PacketHandlerOrderTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
} }
@After @After

View File

@@ -58,7 +58,7 @@ public class RenameUniqueTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class RuntimeExceptionsTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class UnusedFieldsTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class UnusedMethodsTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class UnusedParametersTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -51,7 +51,7 @@ public class ModArithTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -51,7 +51,7 @@ public class MultiplyZeroDeobfuscatorTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class ControlFlowDeobfuscatorTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -50,7 +50,7 @@ public class ConstantParameterTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getVanillaClient())); group = JarUtil.load(new File(properties.getVanillaClient()));
} }
@After @After

View File

@@ -59,7 +59,7 @@ public class MappingDumper
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
} }
@Test @Test
@@ -72,7 +72,7 @@ public class MappingDumper
@Test @Test
public void dump() throws IOException public void dump() throws IOException
{ {
ClassGroup group = JarUtil.loadJar(new File(properties.getRsClient())); ClassGroup group = JarUtil.load(new File(properties.getRsClient()));
final String GAP = "%-40s"; final String GAP = "%-40s";
int classes = 0, methods = 0, fields = 0; int classes = 0, methods = 0, fields = 0;
@@ -321,7 +321,7 @@ public class MappingDumper
@Test @Test
public void dumpTiny() throws IOException public void dumpTiny() throws IOException
{ {
ClassGroup group = JarUtil.loadJar(new File(properties.getRsClient())); ClassGroup group = JarUtil.load(new File(properties.getRsClient()));
System.out.println("v1\tofficial\tintermediary"); System.out.println("v1\tofficial\tintermediary");
for (ClassFile clazz : group.getClasses()) for (ClassFile clazz : group.getClasses())
{ {
@@ -379,7 +379,7 @@ public class MappingDumper
@Test @Test
public void dumpJson() throws IOException public void dumpJson() throws IOException
{ {
ClassGroup group = JarUtil.loadJar(new File(properties.getRsClient())); ClassGroup group = JarUtil.load(new File(properties.getRsClient()));
Gson gson = new GsonBuilder().setPrettyPrinting().create(); Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonObject jObject = new JsonObject(); JsonObject jObject = new JsonObject();

View File

@@ -50,7 +50,7 @@ public class MenuActionDeobfuscatorTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
} }
@After @After

View File

@@ -49,7 +49,7 @@ public class PacketTypeFinderTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
} }
@Test @Test

View File

@@ -51,7 +51,7 @@ public class PacketWriteDeobfuscatorTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
group.removeClass(group.findClass("net/runelite/rs/Reflection")); group.removeClass(group.findClass("net/runelite/rs/Reflection"));
} }

View File

@@ -51,7 +51,7 @@ public class ClientErrorTransformerTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(GAMEPACK); group = JarUtil.load(GAMEPACK);
} }
@After @After

View File

@@ -49,7 +49,7 @@ public class BufferFinderTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
} }
@Test @Test

View File

@@ -31,7 +31,7 @@ public class AnnotationCleaner
{ {
final List<String> missing = new ArrayList<>(); final List<String> missing = new ArrayList<>();
File client = new File(properties.getRsClient()); File client = new File(properties.getRsClient());
ClassGroup group = JarUtil.loadJar(client); ClassGroup group = JarUtil.load(client);
for (ClassFile c : group.getClasses()) for (ClassFile c : group.getClasses())
{ {
@@ -113,7 +113,7 @@ public class AnnotationCleaner
{ {
File client = new File(properties.getRsClient()); File client = new File(properties.getRsClient());
ClassGroup group = JarUtil.loadJar(client); ClassGroup group = JarUtil.load(client);
new AnnotationAdder(group).run(); new AnnotationAdder(group).run();

View File

@@ -47,8 +47,8 @@ public class AnnotationCopierTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group1 = JarUtil.loadJar(new File(JAR1)); group1 = JarUtil.load(new File(JAR1));
group2 = JarUtil.loadJar(new File(JAR2)); group2 = JarUtil.load(new File(JAR2));
} }
@After @After

View File

@@ -42,7 +42,7 @@ public class AnnotationRenamerTest
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(JAR)); group = JarUtil.load(new File(JAR));
} }
@After @After

View File

@@ -62,8 +62,8 @@ public class UpdateMappingsTest
{ {
File client = new File(properties.getRsClient()); File client = new File(properties.getRsClient());
ClassGroup group1 = JarUtil.loadJar(client); ClassGroup group1 = JarUtil.load(client);
ClassGroup group2 = JarUtil.loadJar(new File(JAR)); ClassGroup group2 = JarUtil.load(new File(JAR));
map(group1, group2); map(group1, group2);
@@ -76,8 +76,8 @@ public class UpdateMappingsTest
{ {
File client = new File(properties.getRsClient()); File client = new File(properties.getRsClient());
ClassGroup group1 = JarUtil.loadJar(client); ClassGroup group1 = JarUtil.load(client);
ClassGroup group2 = JarUtil.loadJar(client); ClassGroup group2 = JarUtil.load(client);
// Remove existing annotations // Remove existing annotations
unannotate(group2); unannotate(group2);
@@ -94,7 +94,7 @@ public class UpdateMappingsTest
{ {
File client = new File("C:\\Users\\Lucas\\IdeaProjects\\runelitexxx\\client.jar"); File client = new File("C:\\Users\\Lucas\\IdeaProjects\\runelitexxx\\client.jar");
ClassGroup group = JarUtil.loadJar(client); ClassGroup group = JarUtil.load(client);
new ScriptOpcodesTransformer().transform(group); new ScriptOpcodesTransformer().transform(group);

View File

@@ -72,7 +72,7 @@ public class HookImporter
java.lang.reflect.Type type = new TypeToken<Map<String, ClassHook>>() {}.getType(); java.lang.reflect.Type type = new TypeToken<Map<String, ClassHook>>() {}.getType();
hooks = gson.fromJson(new InputStreamReader(is), type); hooks = gson.fromJson(new InputStreamReader(is), type);
group = JarUtil.loadJar(IN); group = JarUtil.load(IN);
} }
@After @After

View File

@@ -64,7 +64,7 @@ public class MappingImporter
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(IN); group = JarUtil.load(IN);
} }
@After @After

View File

@@ -75,7 +75,7 @@ public class HookImporter
@Before @Before
public void before() throws IOException public void before() throws IOException
{ {
group = JarUtil.loadJar(new File(properties.getRsClient())); group = JarUtil.load(new File(properties.getRsClient()));
InputStream is = getClass().getResourceAsStream("hooks.json"); InputStream is = getClass().getResourceAsStream("hooks.json");
Gson gson = new Gson(); Gson gson = new Gson();

View File

@@ -35,33 +35,25 @@ public class Injector extends InjectData implements InjectTaskHandler
private static final Logger log = Logging.getLogger(Injector.class); private static final Logger log = Logging.getLogger(Injector.class);
private static Injector injector; private static Injector injector;
static File injectedClientOutput = new File("../runelite-client/src/main/resources/net/runelite/client/injected-client.oprs"); static File injectedClient = new File("../runelite-client/src/main/resources/net/runelite/client/injected-client.oprs");
public static void main(String[] args) public static void main(String[] args)
{ {
try File vanillaJar = new File(args[0]);
{ File rsClientJar = new File("../runescape-client/build/libs/runescape-client-" + args[1] + ".jar");
File vanilla = new File(args[0]); File mixinsJar = new File("../runelite-mixins/build/libs/runelite-mixins-" + args[1] + ".jar");
File rsClient = new File("../runescape-client/build/libs/runescape-client-" + args[1] + ".jar"); RSApi rsApiClasses = new RSApi(Objects.requireNonNull(
File mixins = new File("../runelite-mixins/build/libs/runelite-mixins-" + args[1] + ".jar"); new File("../runescape-api/build/classes/java/main/net/runelite/rs/api/")
RSApi rsApi = new RSApi(Objects.requireNonNull( .listFiles()));
new File("../runescape-api/build/classes/java/main/net/runelite/rs/api/")
.listFiles()));
injector = new Injector();
injector.vanilla = JarUtil.loadJar(vanilla);
injector.deobfuscated = JarUtil.loadJar(rsClient);
injector.rsApi = rsApi;
injector.mixins = JarUtil.loadJar(mixins);
injector.initToVanilla();
injector.inject();
save(injectedClientOutput);
}
catch (Exception e)
{
e.printStackTrace();
}
injector = new Injector();
injector.vanilla = JarUtil.load(vanillaJar);
injector.deobfuscated = JarUtil.load(rsClientJar);
injector.rsApi = rsApiClasses;
injector.mixins = JarUtil.load(mixinsJar);
injector.initToVanilla();
injector.inject();
save();
} }
public void inject() public void inject()
@@ -104,11 +96,11 @@ public class Injector extends InjectData implements InjectTaskHandler
transform(new SourceChanger(this)); transform(new SourceChanger(this));
} }
public static void save(File outputJar) public static void save()
{ {
log.info("[INFO] Saving jar to {}", outputJar.toString()); log.info("[INFO] Saving jar to {}", injectedClient.toString());
JarUtil.saveJar(injector.getVanilla(), outputJar); JarUtil.saveJar(injector.getVanilla(), injectedClient);
} }
private void inject(com.openosrs.injector.injectors.Injector injector) private void inject(com.openosrs.injector.injectors.Injector injector)