Package proguard.classfile.editor
Class MethodCopier
- java.lang.Object
-
- proguard.classfile.editor.MethodCopier
-
- All Implemented Interfaces:
AttributeVisitor
,ClassVisitor
,MemberVisitor
public class MethodCopier extends java.lang.Object implements ClassVisitor, MemberVisitor, AttributeVisitor
ThisClassVisitor
copies a method into a target class. It first checks if a method with the same name and descriptor as the method to be copied already exists in the target class. If that is indeed the case, this visitor is a no-op. This visitor optionally uses a name transformer function to apply to the original method's name before copying. If no name transformer function is provided, the original method's name is used, instead. If the method to be copied is indeed copied into the target class, this visitor passes the resulting method to an extra member visitor, if provided.
-
-
Constructor Summary
Constructors Constructor Description MethodCopier(ProgramClass sourceClass, ProgramMethod sourceMethod)
MethodCopier(ProgramClass sourceClass, ProgramMethod sourceMethod, StringFunction nameTransformer)
MethodCopier(ProgramClass sourceClass, ProgramMethod sourceMethod, StringFunction nameTransformer, MemberVisitor extraMemberVisitor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
visitAnyAttribute(Clazz clazz, Attribute attribute)
Visits any Attribute instance.void
visitAnyClass(Clazz clazz)
Visits any Clazz instance.void
visitAnyMember(Clazz clazz, Member member)
Visits any Member instance.void
visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
void
visitProgramClass(ProgramClass programClass)
void
visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface proguard.classfile.attribute.visitor.AttributeVisitor
visitAnnotationDefaultAttribute, visitAnyAnnotationsAttribute, visitAnyParameterAnnotationsAttribute, visitAnyTypeAnnotationsAttribute, visitBootstrapMethodsAttribute, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitEnclosingMethodAttribute, visitExceptionsAttribute, visitInnerClassesAttribute, visitLineNumberTableAttribute, visitLocalVariableTableAttribute, visitLocalVariableTypeTableAttribute, visitMethodParametersAttribute, visitModuleAttribute, visitModuleMainClassAttribute, visitModulePackagesAttribute, visitNestHostAttribute, visitNestMembersAttribute, visitPermittedSubclassesAttribute, visitRecordAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleAnnotationsAttribute, visitRuntimeInvisibleParameterAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeInvisibleTypeAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleAnnotationsAttribute, visitRuntimeVisibleParameterAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitRuntimeVisibleTypeAnnotationsAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSignatureAttribute, visitSourceDebugExtensionAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitStackMapAttribute, visitStackMapTableAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitUnknownAttribute
-
Methods inherited from interface proguard.classfile.visitor.ClassVisitor
visitLibraryClass
-
Methods inherited from interface proguard.classfile.visitor.MemberVisitor
visitLibraryField, visitLibraryMember, visitLibraryMethod, visitProgramField, visitProgramMember
-
-
-
-
Constructor Detail
-
MethodCopier
public MethodCopier(ProgramClass sourceClass, ProgramMethod sourceMethod)
-
MethodCopier
public MethodCopier(ProgramClass sourceClass, ProgramMethod sourceMethod, StringFunction nameTransformer)
-
MethodCopier
public MethodCopier(ProgramClass sourceClass, ProgramMethod sourceMethod, StringFunction nameTransformer, MemberVisitor extraMemberVisitor)
-
-
Method Detail
-
visitAnyClass
public void visitAnyClass(Clazz clazz)
Description copied from interface:ClassVisitor
Visits any Clazz instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyClass
in interfaceClassVisitor
-
visitProgramClass
public void visitProgramClass(ProgramClass programClass)
- Specified by:
visitProgramClass
in interfaceClassVisitor
-
visitAnyMember
public void visitAnyMember(Clazz clazz, Member member)
Description copied from interface:MemberVisitor
Visits any Member instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyMember
in interfaceMemberVisitor
-
visitProgramMethod
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
- Specified by:
visitProgramMethod
in interfaceMemberVisitor
-
visitAnyAttribute
public void visitAnyAttribute(Clazz clazz, Attribute attribute)
Description copied from interface:AttributeVisitor
Visits any Attribute instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyAttribute
in interfaceAttributeVisitor
-
visitCodeAttribute
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
- Specified by:
visitCodeAttribute
in interfaceAttributeVisitor
-
-