Package net.bytebuddy.build
Class RenamingPlugin
- java.lang.Object
-
- net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase
-
- net.bytebuddy.build.RenamingPlugin
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,AsmVisitorWrapper,Plugin,Plugin.Factory,ElementMatcher<TypeDescription>
@Enhance public class RenamingPlugin extends AsmVisitorWrapper.AbstractBase implements Plugin, Plugin.Factory
A plugin that replaces names that are discovered in class files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceRenamingPlugin.RenamingA renaming function tho transform a type's binary name.protected static classRenamingPlugin.RenamingRemapperAn ASMRemapperto apply renamings.-
Nested classes/interfaces inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
AsmVisitorWrapper.AbstractBase, AsmVisitorWrapper.Compound, AsmVisitorWrapper.ForDeclaredFields, AsmVisitorWrapper.ForDeclaredMethods, AsmVisitorWrapper.NoOp
-
Nested 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
-
Nested classes/interfaces inherited from interface net.bytebuddy.build.Plugin.Factory
Plugin.Factory.Simple, Plugin.Factory.UsingReflection
-
-
Field Summary
Fields Modifier and Type Field Description private ElementMatcher<? super TypeDescription>matcherA matcher that determines what types to consider for renaming.private RenamingPlugin.RenamingrenamingThe renaming to apply.-
Fields inherited from interface net.bytebuddy.asm.AsmVisitorWrapper
NO_FLAGS
-
-
Constructor Summary
Constructors Constructor Description RenamingPlugin(java.lang.String pattern, java.lang.String replacement)Creates a renaming plugin for a given regular expression and replacement that applies to all types.RenamingPlugin(java.lang.String pattern, java.lang.String replacement, java.lang.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DynamicType.Builder<?>apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)Applies this plugin.voidclose()Pluginmake()Returns a plugin that can be used for a transformation and which is subsequently closed.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 Detail
-
renaming
private final RenamingPlugin.Renaming renaming
The renaming to apply.
-
matcher
private final ElementMatcher<? super TypeDescription> matcher
A matcher that determines what types to consider for renaming.
-
-
Constructor Detail
-
RenamingPlugin
public RenamingPlugin(java.lang.String pattern, java.lang.String replacement)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
public RenamingPlugin(java.lang.String pattern, java.lang.String replacement, java.lang.String prefix)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
public RenamingPlugin(RenamingPlugin.Renaming renaming)
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 Detail
-
make
public Plugin make()
Returns a plugin that can be used for a transformation and which is subsequently closed.- Specified by:
makein interfacePlugin.Factory- Returns:
- The plugin to use for type transformations.
-
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
public boolean matches(@MaybeNull TypeDescription target)
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 interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
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.
-
-