类 LibraryClassBuilder
java.lang.Object
proguard.classfile.editor.LibraryClassBuilder
This editor allows to build or extend classes (
LibraryClass instances). It provides
methods to easily add interfaces, fields, and methods, optionally with method bodies.
If you're adding many fields and methods, it is more efficient to reuse a single instance of this builder for all fields and methods that you add.
-
构造器概要
构造器构造器说明LibraryClassBuilder(int u2accessFlags, String className, String superclassName) Creates a new ClassBuilder for the Java class with the given name and super class.LibraryClassBuilder(int u2accessFlags, String className, String superclassName, String[] interfaceNames, Clazz[] interfaceClasses, int subClassCount, Clazz[] subClasses, LibraryField[] fields, LibraryMethod[] methods, KotlinMetadata kotlinMetadata) Creates a new ClassBuilder for the Java class with the given name and super class.LibraryClassBuilder(LibraryClass libraryClass) Creates a new ClassBuilder for the given class. -
方法概要
修饰符和类型方法说明addAndReturnField(int u2accessFlags, String fieldName, String fieldDescriptor) Adds a new field to the edited class, and returns it.addAndReturnMethod(int u2accessFlags, String methodName, String methodDescriptor) Adds a new method to the edited class, and returns it.Adds a new field to the edited class.addField(int u2accessFlags, String fieldName, String fieldDescriptor, MemberVisitor extraMemberVisitor) Adds a new field to the edited class.addInterface(String interfaceName) Adds a new interface to the edited class.addInterface(String interfaceName, Clazz referencedInterface) Adds a new interface to the edited class.addInterface(Clazz interfaceClass) Adds a new interface to the edited class.Adds a new method to the edited class.addMethod(int u2accessFlags, String methodName, String methodDescriptor, MemberVisitor extraMemberVisitor) Adds a new method to the edited class.Returns a ConstantPoolEditor instance for the created or edited class instance.Returns the created or edited LibraryClass instance.
-
构造器详细资料
-
LibraryClassBuilder
Creates a new ClassBuilder for the Java class with the given name and super class.- 参数:
u2accessFlags- access flags for the new class.className- the fully qualified name of the new class.superclassName- the fully qualified name of the super class.- 另请参阅:
-
LibraryClassBuilder
public LibraryClassBuilder(int u2accessFlags, String className, String superclassName, String[] interfaceNames, Clazz[] interfaceClasses, int subClassCount, Clazz[] subClasses, LibraryField[] fields, LibraryMethod[] methods, KotlinMetadata kotlinMetadata) Creates a new ClassBuilder for the Java class with the given name and super class.- 参数:
u2accessFlags- access flags for the new class.className- the fully qualified name of the new class.superclassName- the fully qualified name of the super class.interfaceNames- the names of the interfaces that are implemented by this class.interfaceClasses- references to the interface classes of the interfaces that are implemented by this class.subClassCount- the number of subclasses of this class.subClasses- references to the subclasses of this class.fields- references to the fields of this class.methods- references to the methods of this class.kotlinMetadata- the metadata attached to this class if it is a Kotlin class- 另请参阅:
-
LibraryClassBuilder
Creates a new ClassBuilder for the given class.- 参数:
libraryClass- the class to be edited.
-
-
方法详细资料
-
getLibraryClass
Returns the created or edited LibraryClass instance. This is a live instance; any later calls to the builder will still affect the instance. -
getConstantPoolEditor
Returns a ConstantPoolEditor instance for the created or edited class instance. Reusing this instance is more efficient for newly created classes. -
addInterface
Adds a new interface to the edited class.- 参数:
interfaceClass- the interface class.- 返回:
- this instance of ClassBuilder.
-
addInterface
Adds a new interface to the edited class.- 参数:
interfaceName- the name of the interface.- 返回:
- this instance of ClassBuilder.
-
addInterface
Adds a new interface to the edited class.- 参数:
interfaceName- the name of the interface.referencedInterface- the referenced interface.- 返回:
- this instance of ClassBuilder.
-
addField
Adds a new field to the edited class.- 参数:
u2accessFlags- access flags for the new field.fieldName- name of the new field.fieldDescriptor- descriptor of the new field.- 返回:
- this instance of ClassBuilder.
-
addField
public LibraryClassBuilder addField(int u2accessFlags, String fieldName, String fieldDescriptor, MemberVisitor extraMemberVisitor) Adds a new field to the edited class.- 参数:
u2accessFlags- access flags for the new field.fieldName- name of the new field.fieldDescriptor- descriptor of the new field.- 返回:
- this instance of ClassBuilder.
-
addAndReturnField
Adds a new field to the edited class, and returns it.- 参数:
u2accessFlags- access flags for the new field.fieldName- name of the new field.fieldDescriptor- descriptor of the new field.- 返回:
- the newly created field.
-
addMethod
Adds a new method to the edited class.- 参数:
u2accessFlags- the access flags of the new method.methodName- the name of the new method.methodDescriptor- the descriptor of the new method.- 返回:
- this instance of ClassBuilder.
-
addMethod
public LibraryClassBuilder addMethod(int u2accessFlags, String methodName, String methodDescriptor, MemberVisitor extraMemberVisitor) Adds a new method to the edited class.- 参数:
u2accessFlags- the access flags of the new method.methodName- the name of the new method.methodDescriptor- the descriptor of the new method.extraMemberVisitor- an optional visitor for the method after it has been created and added to the class.- 返回:
- this instance of ClassBuilder.
-
addAndReturnMethod
public LibraryMethod addAndReturnMethod(int u2accessFlags, String methodName, String methodDescriptor) Adds a new method to the edited class, and returns it.- 参数:
u2accessFlags- the access flags of the new method.methodName- the name of the new method.methodDescriptor- the descriptor of the new method.- 返回:
- the newly created method.
-