Package org.jf.dexlib2.rewriter
Class DexRewriter
- java.lang.Object
-
- org.jf.dexlib2.rewriter.DexRewriter
-
- All Implemented Interfaces:
Rewriters
public class DexRewriter extends java.lang.Object implements Rewriters
Out-of-the box, this class does nothing except make a picture-perfect copy of a dex file. However, it provides many points where you can hook into this process and selectively modify the dex file. For example, If you want to rename all instances (including definitions and references) of the class Lorg/blah/MyBlah; to Lorg/blah/YourBlah;DexRewriter rewriter = new DexRewriter(new RewriterModule() { public Rewriter<String> getTypeRewriter(Rewriters rewriters) { return new Rewriter<String>() { public String rewrite(String value) { if (value.equals("Lorg/blah/MyBlah;")) { return "Lorg/blah/YourBlah;"; } return value; } }; } }); DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexFile);
-
-
Constructor Summary
Constructors Constructor Description DexRewriter(RewriterModule module)
-
Method Summary
-
-
-
Constructor Detail
-
DexRewriter
public DexRewriter(RewriterModule module)
-
-
Method Detail
-
getDexFileRewriter
@Nonnull public Rewriter<DexFile> getDexFileRewriter()
- Specified by:
getDexFileRewriter
in interfaceRewriters
-
getClassDefRewriter
@Nonnull public Rewriter<ClassDef> getClassDefRewriter()
- Specified by:
getClassDefRewriter
in interfaceRewriters
-
getFieldRewriter
@Nonnull public Rewriter<Field> getFieldRewriter()
- Specified by:
getFieldRewriter
in interfaceRewriters
-
getMethodRewriter
@Nonnull public Rewriter<Method> getMethodRewriter()
- Specified by:
getMethodRewriter
in interfaceRewriters
-
getMethodParameterRewriter
@Nonnull public Rewriter<MethodParameter> getMethodParameterRewriter()
- Specified by:
getMethodParameterRewriter
in interfaceRewriters
-
getMethodImplementationRewriter
@Nonnull public Rewriter<MethodImplementation> getMethodImplementationRewriter()
- Specified by:
getMethodImplementationRewriter
in interfaceRewriters
-
getInstructionRewriter
@Nonnull public Rewriter<Instruction> getInstructionRewriter()
- Specified by:
getInstructionRewriter
in interfaceRewriters
-
getTryBlockRewriter
@Nonnull public Rewriter<TryBlock<? extends ExceptionHandler>> getTryBlockRewriter()
- Specified by:
getTryBlockRewriter
in interfaceRewriters
-
getExceptionHandlerRewriter
@Nonnull public Rewriter<ExceptionHandler> getExceptionHandlerRewriter()
- Specified by:
getExceptionHandlerRewriter
in interfaceRewriters
-
getDebugItemRewriter
@Nonnull public Rewriter<DebugItem> getDebugItemRewriter()
- Specified by:
getDebugItemRewriter
in interfaceRewriters
-
getTypeRewriter
@Nonnull public Rewriter<java.lang.String> getTypeRewriter()
- Specified by:
getTypeRewriter
in interfaceRewriters
-
getFieldReferenceRewriter
@Nonnull public Rewriter<FieldReference> getFieldReferenceRewriter()
- Specified by:
getFieldReferenceRewriter
in interfaceRewriters
-
getMethodReferenceRewriter
@Nonnull public Rewriter<MethodReference> getMethodReferenceRewriter()
- Specified by:
getMethodReferenceRewriter
in interfaceRewriters
-
getAnnotationRewriter
@Nonnull public Rewriter<Annotation> getAnnotationRewriter()
- Specified by:
getAnnotationRewriter
in interfaceRewriters
-
getAnnotationElementRewriter
@Nonnull public Rewriter<AnnotationElement> getAnnotationElementRewriter()
- Specified by:
getAnnotationElementRewriter
in interfaceRewriters
-
getEncodedValueRewriter
@Nonnull public Rewriter<EncodedValue> getEncodedValueRewriter()
- Specified by:
getEncodedValueRewriter
in interfaceRewriters
-
-