-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write decompiler filters for dropping illegal annotations and local v…
…ariable tables
- Loading branch information
Showing
4 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/main/java/club/bytecode/the/jda/decompilers/filter/DropLocalVariableTableFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package club.bytecode.the.jda.decompilers.filter; | ||
|
||
import club.bytecode.the.jda.JDA; | ||
import club.bytecode.the.jda.api.JDANamespace; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
public class DropLocalVariableTableFilter implements DecompileFilter { | ||
@Override | ||
public void process(ClassNode cn) { | ||
cn.methods.forEach(methodNode -> methodNode.localVariables.clear()); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Drop local variable table"; | ||
} | ||
|
||
@Override | ||
public JDANamespace getNamespace() { | ||
return JDA.namespace; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/club/bytecode/the/jda/decompilers/filter/IllegalAnnotationFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package club.bytecode.the.jda.decompilers.filter; | ||
|
||
import club.bytecode.the.jda.JDA; | ||
import club.bytecode.the.jda.api.JDANamespace; | ||
import org.objectweb.asm.tree.ClassNode; | ||
|
||
public class IllegalAnnotationFilter implements DecompileFilter { | ||
@Override | ||
public void process(ClassNode cn) { | ||
cn.methods.forEach(methodNode -> { | ||
if (methodNode.invisibleAnnotations != null) | ||
methodNode.invisibleAnnotations.removeIf(node -> node.desc.equals("@")); | ||
}); | ||
|
||
if (cn.invisibleAnnotations != null) | ||
cn.invisibleAnnotations.removeIf(node -> node.desc.equals("@")); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Kill illegal annotations"; | ||
} | ||
|
||
@Override | ||
public JDANamespace getNamespace() { | ||
return JDA.namespace; | ||
} | ||
} |