From 5b12c57588c0dd57c40ff6f6481b32710a7b1a3b Mon Sep 17 00:00:00 2001 From: REAndroid Date: Fri, 5 Apr 2024 21:35:32 +0200 Subject: [PATCH] [Dex] Convenient code & debug clear methods --- src/main/java/com/reandroid/dex/data/MethodDef.java | 9 +++++++++ src/main/java/com/reandroid/dex/model/DexMethod.java | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/reandroid/dex/data/MethodDef.java b/src/main/java/com/reandroid/dex/data/MethodDef.java index c82c6af79..5127868a2 100644 --- a/src/main/java/com/reandroid/dex/data/MethodDef.java +++ b/src/main/java/com/reandroid/dex/data/MethodDef.java @@ -239,6 +239,15 @@ public CodeItem getCodeItem(){ } return codeItem; } + public void clearCode(){ + codeOffset.setItem((CodeItem) null); + } + public void clearDebug(){ + CodeItem codeItem = getCodeItem(); + if(codeItem != null){ + codeItem.removeDebugInfo(); + } + } private void linkCodeItem(){ CodeItem codeItem = codeOffset.getItem(); if(codeItem != null){ diff --git a/src/main/java/com/reandroid/dex/model/DexMethod.java b/src/main/java/com/reandroid/dex/model/DexMethod.java index 811446022..fc8180495 100644 --- a/src/main/java/com/reandroid/dex/model/DexMethod.java +++ b/src/main/java/com/reandroid/dex/model/DexMethod.java @@ -26,7 +26,6 @@ import com.reandroid.dex.key.Key; import com.reandroid.dex.key.MethodKey; import com.reandroid.dex.key.TypeKey; -import com.reandroid.dex.smali.SmaliParser; import com.reandroid.dex.smali.SmaliReader; import com.reandroid.dex.smali.SmaliWriter; import com.reandroid.dex.smali.model.SmaliInstruction; @@ -160,6 +159,12 @@ public Iterator getInstructions(Predicate filter) { public Iterator getInstructions() { return DexInstruction.create(this, getDefinition().getInstructions()); } + public void clearCode(){ + getDefinition().clearCode(); + } + public void clearDebug(){ + getDefinition().clearDebug(); + } public Iterator getDexTry() { TryBlock tryBlock = getDefinition().getTryBlock(); if(tryBlock == null){