public class ClassReferenceFixer extends java.lang.Object implements ClassVisitor, ConstantVisitor, MemberVisitor, AttributeVisitor, RecordComponentInfoVisitor, InnerClassesInfoVisitor, LocalVariableInfoVisitor, LocalVariableTypeInfoVisitor, AnnotationVisitor, ElementValueVisitor
ClassVisitor
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.MemberReferenceFixer
Modifier and Type | Class and Description |
---|---|
static interface |
ClassReferenceFixer.NameGenerationStrategy
This interface provides an abstraction on how a
Member should be renamed when its
descriptor need to be updated. |
Constructor and Description |
---|
ClassReferenceFixer(boolean ensureUniqueMemberNames)
Creates a new ClassReferenceFixer.
|
ClassReferenceFixer(ClassReferenceFixer.NameGenerationStrategy newNameStrategy)
Creates a new ClassReferenceFixer.
|
Modifier and Type | Method and 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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
visitAnyMethodrefConstant, visitAnyRefConstant, visitDoubleConstant, visitFieldrefConstant, visitFloatConstant, visitIntegerConstant, visitInterfaceMethodrefConstant, visitLongConstant, visitMethodHandleConstant, visitMethodrefConstant, visitModuleConstant, visitNameAndTypeConstant, visitPackageConstant, visitPrimitiveArrayConstant, visitUtf8Constant
visitAnyMember, visitLibraryMember, visitProgramMember
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
visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation, visitAnnotation
visitAnyElementValue
public ClassReferenceFixer(boolean ensureUniqueMemberNames)
ensureUniqueMemberNames
- specifies whether class members whose descriptor changes should
get new, unique names, in order to avoid naming conflicts with similar methods.public ClassReferenceFixer(ClassReferenceFixer.NameGenerationStrategy newNameStrategy)
newNameStrategy
- specifies how class members whose descriptor changes should get a new
name in order to avoid naming conflicts with similar members.public void visitAnyClass(Clazz clazz)
ClassVisitor
visitAnyClass
in interface ClassVisitor
public void visitProgramClass(ProgramClass programClass)
visitProgramClass
in interface ClassVisitor
public void visitLibraryClass(LibraryClass libraryClass)
visitLibraryClass
in interface ClassVisitor
public void visitProgramField(ProgramClass programClass, ProgramField programField)
visitProgramField
in interface MemberVisitor
public void visitProgramMethod(ProgramClass programClass, ProgramMethod programMethod)
visitProgramMethod
in interface MemberVisitor
public void visitLibraryField(LibraryClass libraryClass, LibraryField libraryField)
visitLibraryField
in interface MemberVisitor
public void visitLibraryMethod(LibraryClass libraryClass, LibraryMethod libraryMethod)
visitLibraryMethod
in interface MemberVisitor
public void visitAnyConstant(Clazz clazz, Constant constant)
ConstantVisitor
visitAnyConstant
in interface ConstantVisitor
public void visitStringConstant(Clazz clazz, StringConstant stringConstant)
visitStringConstant
in interface ConstantVisitor
public void visitDynamicConstant(Clazz clazz, DynamicConstant dynamicConstant)
visitDynamicConstant
in interface ConstantVisitor
public void visitInvokeDynamicConstant(Clazz clazz, InvokeDynamicConstant invokeDynamicConstant)
visitInvokeDynamicConstant
in interface ConstantVisitor
public void visitClassConstant(Clazz clazz, ClassConstant classConstant)
visitClassConstant
in interface ConstantVisitor
public void visitMethodTypeConstant(Clazz clazz, MethodTypeConstant methodTypeConstant)
visitMethodTypeConstant
in interface ConstantVisitor
public void visitAnyAttribute(Clazz clazz, Attribute attribute)
AttributeVisitor
visitAnyAttribute
in interface AttributeVisitor
public void visitRecordAttribute(Clazz clazz, RecordAttribute recordAttribute)
visitRecordAttribute
in interface AttributeVisitor
public void visitInnerClassesAttribute(Clazz clazz, InnerClassesAttribute innerClassesAttribute)
visitInnerClassesAttribute
in interface AttributeVisitor
public void visitCodeAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute)
visitCodeAttribute
in interface AttributeVisitor
public void visitLocalVariableTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTableAttribute localVariableTableAttribute)
visitLocalVariableTableAttribute
in interface AttributeVisitor
public void visitLocalVariableTypeTableAttribute(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeTableAttribute localVariableTypeTableAttribute)
visitLocalVariableTypeTableAttribute
in interface AttributeVisitor
public void visitSignatureAttribute(Clazz clazz, SignatureAttribute signatureAttribute)
visitSignatureAttribute
in interface AttributeVisitor
public void visitAnyAnnotationsAttribute(Clazz clazz, AnnotationsAttribute annotationsAttribute)
AttributeVisitor
visitAnyAnnotationsAttribute
in interface AttributeVisitor
public void visitAnyParameterAnnotationsAttribute(Clazz clazz, Method method, ParameterAnnotationsAttribute parameterAnnotationsAttribute)
AttributeVisitor
visitAnyParameterAnnotationsAttribute
in interface AttributeVisitor
public void visitAnnotationDefaultAttribute(Clazz clazz, Method method, AnnotationDefaultAttribute annotationDefaultAttribute)
visitAnnotationDefaultAttribute
in interface AttributeVisitor
public void visitRecordComponentInfo(Clazz clazz, RecordComponentInfo recordComponentInfo)
visitRecordComponentInfo
in interface RecordComponentInfoVisitor
public void visitInnerClassesInfo(Clazz clazz, InnerClassesInfo innerClassesInfo)
visitInnerClassesInfo
in interface InnerClassesInfoVisitor
public void visitLocalVariableInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableInfo localVariableInfo)
visitLocalVariableInfo
in interface LocalVariableInfoVisitor
public void visitLocalVariableTypeInfo(Clazz clazz, Method method, CodeAttribute codeAttribute, LocalVariableTypeInfo localVariableTypeInfo)
visitLocalVariableTypeInfo
in interface LocalVariableTypeInfoVisitor
public void visitAnnotation(Clazz clazz, Annotation annotation)
AnnotationVisitor
visitAnnotation
in interface AnnotationVisitor
public void visitConstantElementValue(Clazz clazz, Annotation annotation, ConstantElementValue constantElementValue)
visitConstantElementValue
in interface ElementValueVisitor
public void visitEnumConstantElementValue(Clazz clazz, Annotation annotation, EnumConstantElementValue enumConstantElementValue)
visitEnumConstantElementValue
in interface ElementValueVisitor
public void visitClassElementValue(Clazz clazz, Annotation annotation, ClassElementValue classElementValue)
visitClassElementValue
in interface ElementValueVisitor
public void visitAnnotationElementValue(Clazz clazz, Annotation annotation, AnnotationElementValue annotationElementValue)
visitAnnotationElementValue
in interface ElementValueVisitor
public void visitArrayElementValue(Clazz clazz, Annotation annotation, ArrayElementValue arrayElementValue)
visitArrayElementValue
in interface ElementValueVisitor
public static java.lang.String shortKotlinNestedClassName(java.lang.String enclosingClassName, java.lang.String shortInnerClassName, Clazz referencedClass)
public static java.lang.String newDescriptor(java.lang.String descriptor, Clazz[] referencedClasses)