Package net.bytebuddy.build
Class RenamingPlugin
java.lang.Object
net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
net.bytebuddy.build.RenamingPlugin
- All Implemented Interfaces:
Closeable,AutoCloseable,AsmVisitorWrapper,Plugin,ElementMatcher<TypeDescription>
A plugin that replaces names that are discovered in class files.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA renaming function tho transform a type's binary name.protected static classAn ASMRemapperto apply renamings.Nested classes/interfaces inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
AsmVisitorWrapper.AbstractBase, AsmVisitorWrapper.Compound, AsmVisitorWrapper.ForDeclaredFields, AsmVisitorWrapper.ForDeclaredMethods, AsmVisitorWrapper.NoOpNested classes/interfaces inherited from interface net.bytebuddy.matcher.ElementMatcher
ElementMatcher.Junction<S>Nested classes/interfaces inherited from interface net.bytebuddy.build.Plugin
Plugin.Engine, Plugin.Factory, Plugin.ForElementMatcher, Plugin.NoOp, Plugin.WithInitialization, Plugin.WithPreprocessor -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ElementMatcher<? super TypeDescription> A matcher that determines what types to consider for renaming.private final RenamingPlugin.RenamingThe renaming to apply.Fields inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
NO_FLAGS -
Constructor Summary
ConstructorsConstructorDescriptionRenamingPlugin(String pattern, String replacement) Creates a renaming plugin for a given regular expression and replacement that applies to all types.RenamingPlugin(String pattern, String replacement, String prefix) Creates a renaming plugin for a given regular expression and replacement that applies to all types that start with a given prefix.RenamingPlugin(RenamingPlugin.Renaming renaming) Creates a renaming plugin for the given renaming that applies to all types.RenamingPlugin(RenamingPlugin.Renaming renaming, ElementMatcher<? super TypeDescription> matcher) Creates a renaming plugin for the given renaming and type matcher. -
Method Summary
Modifier and TypeMethodDescriptionapply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator) Applies this plugin.voidclose()booleanmatches(TypeDescription target) Matches a target against this element matcher.org.objectweb.asm.ClassVisitorwrap(TypeDescription instrumentedType, org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags) Applies aClassVisitorWrapperto the creation of aDynamicType.Methods inherited from class net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
mergeReader, mergeWriter
-
Field Details
-
renaming
The renaming to apply. -
matcher
A matcher that determines what types to consider for renaming.
-
-
Constructor Details
-
RenamingPlugin
Creates a renaming plugin for a given regular expression and replacement that applies to all types.- Parameters:
pattern- The pattern to consider.replacement- The replacement to apply if the supplied pattern is matched.
-
RenamingPlugin
Creates a renaming plugin for a given regular expression and replacement that applies to all types that start with a given prefix.- Parameters:
pattern- The pattern to consider.replacement- The replacement to apply if the supplied pattern is matched.prefix- The prefix for types to consider for renaming.
-
RenamingPlugin
Creates a renaming plugin for the given renaming that applies to all types.- Parameters:
renaming- The renaming to apply.
-
RenamingPlugin
public RenamingPlugin(RenamingPlugin.Renaming renaming, ElementMatcher<? super TypeDescription> matcher) Creates a renaming plugin for the given renaming and type matcher.- Parameters:
renaming- The renaming to apply.matcher- A matcher that determines what types to consider for renaming.
-
-
Method Details
-
apply
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator) Applies this plugin.- Specified by:
applyin interfacePlugin- Parameters:
builder- The builder to use as a basis for the applied transformation.typeDescription- The type being transformed.classFileLocator- A class file locator that can locate other types in the scope of the project.- Returns:
- The supplied builder with additional transformations registered.
-
matches
Matches a target against this element matcher.- Specified by:
matchesin interfaceElementMatcher<TypeDescription>- Parameters:
target- The instance to be matched ornull.- Returns:
trueif the given element is matched by this matcher orfalseotherwise.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
wrap
public org.objectweb.asm.ClassVisitor wrap(TypeDescription instrumentedType, org.objectweb.asm.ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags) Applies aClassVisitorWrapperto the creation of aDynamicType.- Specified by:
wrapin interfaceAsmVisitorWrapper- Parameters:
instrumentedType- The instrumented type.classVisitor- AClassVisitorto become the new primary class visitor to which the createdDynamicTypeis written to.implementationContext- The implementation context of the current instrumentation.typePool- The type pool that was provided for the class creation.fields- The instrumented type's fields.methods- The instrumented type's methods non-ignored declared and virtually inherited methods.writerFlags- The ASMClassWriterflags to consider.readerFlags- The ASMClassReaderflags to consider.- Returns:
- A new
ClassVisitorthat usually delegates to theClassVisitordelivered in the argument.
-