File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed
src/main/java/rs/lostcity/deob/bytecode/transform/openrs2 Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change 77import rs .lostcity .asm .transform .Transformer ;
88
99import java .util .List ;
10+ import java .util .Objects ;
1011
1112/**
1213 * A [Transformer] responsible for removing [ZKM](http://www.zelix.com/klassmaster/)'s
@@ -26,19 +27,25 @@ public void preTransform(List<ClassNode> classes) {
2627 @ Override
2728 public boolean transformCode (List <ClassNode > classes , ClassNode clazz , MethodNode method ) {
2829 for (var insn : method .instructions ) {
29- if (insn .getOpcode () != Opcodes .ATHROW ) {
30- continue ;
31- }
32-
33- var foundTryCatch = method .tryCatchBlocks .removeIf (tryCatch ->
34- InsnNodeUtil .getNextReal (tryCatch .handler ).equals (insn ));
35-
36- if (foundTryCatch ) {
37- method .instructions .remove (insn );
38- handlers ++;
30+ if (insn .getOpcode () == Opcodes .ATHROW ) {
31+ // redundant throw
32+ var foundTryCatch = method .tryCatchBlocks .removeIf (tryCatch ->
33+ InsnNodeUtil .getNextReal (tryCatch .handler ).equals (insn ));
34+
35+ if (foundTryCatch ) {
36+ method .instructions .remove (insn );
37+ handlers ++;
38+ }
3939 }
4040 }
4141
42+ int before = method .tryCatchBlocks .size ();
43+ // todo: this may result in synchronized blocks going unused
44+ method .tryCatchBlocks .removeIf (tryCatch -> tryCatch .type == null );
45+ // todo: confirm this is fine, early clients don't need throwable for any legitimate use
46+ method .tryCatchBlocks .removeIf (tryCatch -> Objects .equals (tryCatch .type , "java/lang/Throwable" ));
47+ handlers += before - method .tryCatchBlocks .size ();
48+
4249 return false ;
4350 }
4451
You can’t perform that action at this time.
0 commit comments