Package proguard.classfile.editor
Class ClassReferenceFixer
- java.lang.Object
-
- proguard.classfile.editor.ClassReferenceFixer
-
- All Implemented Interfaces:
AnnotationVisitor
,ElementValueVisitor
,AttributeVisitor
,InnerClassesInfoVisitor
,LocalVariableInfoVisitor
,LocalVariableTypeInfoVisitor
,RecordComponentInfoVisitor
,ConstantVisitor
,ClassVisitor
,MemberVisitor
public class ClassReferenceFixer extends java.lang.Object implements ClassVisitor, ConstantVisitor, MemberVisitor, AttributeVisitor, RecordComponentInfoVisitor, InnerClassesInfoVisitor, LocalVariableInfoVisitor, LocalVariableTypeInfoVisitor, AnnotationVisitor, ElementValueVisitor
ThisClassVisitor
fixes references of constant pool entries, fields, methods, attributes and kotlin metadata to classes whose names have changed. Descriptors of programMember references are not updated yet.- See Also:
MemberReferenceFixer
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ClassReferenceFixer.NameGenerationStrategy
This interface provides an abstraction on how aMember
should be renamed when its descriptor need to be updated.
-
Constructor Summary
Constructors Constructor Description ClassReferenceFixer(boolean ensureUniqueMemberNames)
Creates a new ClassReferenceFixer.ClassReferenceFixer(ClassReferenceFixer.NameGenerationStrategy newNameStrategy)
Creates a new ClassReferenceFixer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.lang.String
newDescriptor(java.lang.String descriptor, Clazz[] referencedClasses)
Returns the new descriptor of a method after applying the obfuscation, given the old descriptor and the referenced classes.static java.lang.String
shortKotlinNestedClassName(java.lang.String enclosingClassName, java.lang.String shortInnerClassName, Clazz referencedClass)
Returns the short classname to be used as the nested classname.void
visitAnnotation(Clazz clazz, Annotation annotation)
Visits any Annotation instance.void
visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute)
void
visitAnnotationElementValue(Clazz clazz, Annotation annotation, AnnotationElementValue annotationElementValue)
void
visitAnyAnnotationsAttribute(Clazz clazz, AnnotationsAttribute annotationsAttribute)
Visits any AnnotationsAttribute instance.void
visitAnyAttribute(Clazz clazz, Attribute attribute)
Visits any Attribute instance.void
visitAnyClass(Clazz clazz)
Visits any Clazz instance.void
visitAnyConstant(Clazz clazz, Constant constant)
Visits any Constant instance.void
visitAnyParameterAnnotationsAttribute(Clazz clazz, Method method, ParameterAnnotationsAttribute parameterAnnotationsAttribute)
Visits any ParameterAnnotationsAttribute instance.void
visitArrayElementValue(Clazz clazz, Annotation annotation, ArrayElementValue arrayElementValue)
void
visitClassConstant(Clazz clazz, ClassConstant classConstant)
void
visitClassElementValue(Clazz clazz, Annotation annotation, ClassElementValue classElementValue)
void
visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
void
visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue)
void
visitDynamicConstant(Clazz clazz, DynamicConstant dynamicConstant)
void
visitEnumConstantElementValue(Clazz clazz, Annotation annotation, EnumConstantElementValue enumConstantElementValue)
void
visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute)
void
visitInnerClassesInfo(Clazz clazz, InnerClassesInfo innerClassesInfo)
void
visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
void
visitLibraryClass(LibraryClass libraryClass)
void
visitLibraryField(LibraryClass libraryClass, LibraryField libraryField)
void
visitLibraryMethod(LibraryClass libraryClass, LibraryMethod libraryMethod)
void
visitLocalVariableInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfo localVariableInfo)
void
visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute)
void
visitLocalVariableTypeInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfo localVariableTypeInfo)
void
visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute)
void
visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
void
visitProgramClass(ProgramClass programClass)
void
visitProgramField(ProgramClass programClass, ProgramField programField)
void
visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
void
visitRecordAttribute(Clazz clazz, RecordAttribute recordAttribute)
void
visitRecordComponentInfo(Clazz clazz, RecordComponentInfo recordComponentInfo)
void
visitSignatureAttribute(Clazz clazz, SignatureAttribute signatureAttribute)
void
visitStringConstant(Clazz clazz, StringConstant stringConstant)
-
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.annotation.visitor.AnnotationVisitor
visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation
-
Methods inherited from interface proguard.classfile.attribute.visitor.AttributeVisitor
visitAnyTypeAnnotationsAttribute, visitBootstrapMethodsAttribute, visitConstantValueAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitDeprecatedAttribute, visitEnclosingMethodAttribute, visitExceptionsAttribute, visitLineNumberTableAttribute, visitMethodParametersAttribute, visitModuleAttribute, visitModuleMainClassAttribute, visitModulePackagesAttribute, visitNestHostAttribute, visitNestMembersAttribute, visitPermittedSubclassesAttribute, 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, visitSourceDebugExtensionAttribute, visitSourceDirAttribute, visitSourceFileAttribute, visitStackMapAttribute, visitStackMapTableAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitSyntheticAttribute, visitUnknownAttribute
-
Methods inherited from interface proguard.classfile.constant.visitor.ConstantVisitor
visitAnyMethodrefConstant, visitAnyRefConstant, visitDoubleConstant, visitFieldrefConstant, visitFloatConstant, visitIntegerConstant, visitInterfaceMethodrefConstant, visitLongConstant, visitMethodHandleConstant, visitMethodrefConstant, visitModuleConstant, visitNameAndTypeConstant, visitPackageConstant, visitPrimitiveArrayConstant, visitUtf8Constant
-
Methods inherited from interface proguard.classfile.attribute.annotation.visitor.ElementValueVisitor
visitAnyElementValue
-
Methods inherited from interface proguard.classfile.visitor.MemberVisitor
visitAnyMember, visitLibraryMember, visitProgramMember
-
-
-
-
Constructor Detail
-
ClassReferenceFixer
public ClassReferenceFixer(boolean ensureUniqueMemberNames)
Creates a new ClassReferenceFixer.- Parameters:
ensureUniqueMemberNames
- specifies whether class members whose descriptor changes should get new, unique names, in order to avoid naming conflicts with similar methods.
-
ClassReferenceFixer
public ClassReferenceFixer(ClassReferenceFixer.NameGenerationStrategy newNameStrategy)
Creates a new ClassReferenceFixer.- Parameters:
newNameStrategy
- specifies how class members whose descriptor changes should get a new name in order to avoid naming conflicts with similar members.
-
-
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
-
visitLibraryClass
public void visitLibraryClass(LibraryClass libraryClass)
- Specified by:
visitLibraryClass
in interfaceClassVisitor
-
visitProgramField
public void visitProgramField(ProgramClass programClass, ProgramField programField)
- Specified by:
visitProgramField
in interfaceMemberVisitor
-
visitProgramMethod
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
- Specified by:
visitProgramMethod
in interfaceMemberVisitor
-
visitLibraryField
public void visitLibraryField(LibraryClass libraryClass, LibraryField libraryField)
- Specified by:
visitLibraryField
in interfaceMemberVisitor
-
visitLibraryMethod
public void visitLibraryMethod(LibraryClass libraryClass, LibraryMethod libraryMethod)
- Specified by:
visitLibraryMethod
in interfaceMemberVisitor
-
visitAnyConstant
public void visitAnyConstant(Clazz clazz, Constant constant)
Description copied from interface:ConstantVisitor
Visits any Constant instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyConstant
in interfaceConstantVisitor
-
visitStringConstant
public void visitStringConstant(Clazz clazz, StringConstant stringConstant)
- Specified by:
visitStringConstant
in interfaceConstantVisitor
-
visitDynamicConstant
public void visitDynamicConstant(Clazz clazz, DynamicConstant dynamicConstant)
- Specified by:
visitDynamicConstant
in interfaceConstantVisitor
-
visitInvokeDynamicConstant
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
- Specified by:
visitInvokeDynamicConstant
in interfaceConstantVisitor
-
visitClassConstant
public void visitClassConstant(Clazz clazz, ClassConstant classConstant)
- Specified by:
visitClassConstant
in interfaceConstantVisitor
-
visitMethodTypeConstant
public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
- Specified by:
visitMethodTypeConstant
in interfaceConstantVisitor
-
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
-
visitRecordAttribute
public void visitRecordAttribute(Clazz clazz, RecordAttribute recordAttribute)
- Specified by:
visitRecordAttribute
in interfaceAttributeVisitor
-
visitInnerClassesAttribute
public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute)
- Specified by:
visitInnerClassesAttribute
in interfaceAttributeVisitor
-
visitCodeAttribute
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
- Specified by:
visitCodeAttribute
in interfaceAttributeVisitor
-
visitLocalVariableTableAttribute
public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute)
- Specified by:
visitLocalVariableTableAttribute
in interfaceAttributeVisitor
-
visitLocalVariableTypeTableAttribute
public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute)
- Specified by:
visitLocalVariableTypeTableAttribute
in interfaceAttributeVisitor
-
visitSignatureAttribute
public void visitSignatureAttribute(Clazz clazz, SignatureAttribute signatureAttribute)
- Specified by:
visitSignatureAttribute
in interfaceAttributeVisitor
-
visitAnyAnnotationsAttribute
public void visitAnyAnnotationsAttribute(Clazz clazz, AnnotationsAttribute annotationsAttribute)
Description copied from interface:AttributeVisitor
Visits any AnnotationsAttribute instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyAnnotationsAttribute
in interfaceAttributeVisitor
-
visitAnyParameterAnnotationsAttribute
public void visitAnyParameterAnnotationsAttribute(Clazz clazz, Method method, ParameterAnnotationsAttribute parameterAnnotationsAttribute)
Description copied from interface:AttributeVisitor
Visits any ParameterAnnotationsAttribute instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnyParameterAnnotationsAttribute
in interfaceAttributeVisitor
-
visitAnnotationDefaultAttribute
public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute)
- Specified by:
visitAnnotationDefaultAttribute
in interfaceAttributeVisitor
-
visitRecordComponentInfo
public void visitRecordComponentInfo(Clazz clazz, RecordComponentInfo recordComponentInfo)
- Specified by:
visitRecordComponentInfo
in interfaceRecordComponentInfoVisitor
-
visitInnerClassesInfo
public void visitInnerClassesInfo(Clazz clazz, InnerClassesInfo innerClassesInfo)
- Specified by:
visitInnerClassesInfo
in interfaceInnerClassesInfoVisitor
-
visitLocalVariableInfo
public void visitLocalVariableInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfo localVariableInfo)
- Specified by:
visitLocalVariableInfo
in interfaceLocalVariableInfoVisitor
-
visitLocalVariableTypeInfo
public void visitLocalVariableTypeInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfo localVariableTypeInfo)
- Specified by:
visitLocalVariableTypeInfo
in interfaceLocalVariableTypeInfoVisitor
-
visitAnnotation
public void visitAnnotation(Clazz clazz, Annotation annotation)
Description copied from interface:AnnotationVisitor
Visits any Annotation instance. The more specific default implementations of this interface delegate to this method.- Specified by:
visitAnnotation
in interfaceAnnotationVisitor
-
visitConstantElementValue
public void visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue)
- Specified by:
visitConstantElementValue
in interfaceElementValueVisitor
-
visitEnumConstantElementValue
public void visitEnumConstantElementValue(Clazz clazz, Annotation annotation, EnumConstantElementValue enumConstantElementValue)
- Specified by:
visitEnumConstantElementValue
in interfaceElementValueVisitor
-
visitClassElementValue
public void visitClassElementValue(Clazz clazz, Annotation annotation, ClassElementValue classElementValue)
- Specified by:
visitClassElementValue
in interfaceElementValueVisitor
-
visitAnnotationElementValue
public void visitAnnotationElementValue(Clazz clazz, Annotation annotation, AnnotationElementValue annotationElementValue)
- Specified by:
visitAnnotationElementValue
in interfaceElementValueVisitor
-
visitArrayElementValue
public void visitArrayElementValue(Clazz clazz, Annotation annotation, ArrayElementValue arrayElementValue)
- Specified by:
visitArrayElementValue
in interfaceElementValueVisitor
-
shortKotlinNestedClassName
public static java.lang.String shortKotlinNestedClassName(java.lang.String enclosingClassName, java.lang.String shortInnerClassName, Clazz referencedClass)
Returns the short classname to be used as the nested classname.
-
newDescriptor
public static java.lang.String newDescriptor(java.lang.String descriptor, Clazz[] referencedClasses)
Returns the new descriptor of a method after applying the obfuscation, given the old descriptor and the referenced classes.
-
-