Top Description Inners Fields Constructors Methods
net.bytebuddy.build

public Class RenamingPlugin

extends AbstractBase
implements Plugin
Class Inheritance
All Implemented Interfaces
net.bytebuddy.build.Plugin, java.io.Closeable, java.lang.AutoCloseable, net.bytebuddy.matcher.ElementMatcher
Annotations
@Enhance
Imports
net.bytebuddy.asm.AsmVisitorWrapper, net.bytebuddy.description.field.FieldDescription, .FieldList, net.bytebuddy.description.method.MethodList, net.bytebuddy.description.type.TypeDescription, net.bytebuddy.dynamic.ClassFileLocator, .DynamicType, net.bytebuddy.implementation.Implementation, net.bytebuddy.matcher.ElementMatcher, net.bytebuddy.pool.TypePool, net.bytebuddy.jar.asm.ClassVisitor, net.bytebuddy.jar.asm.commons.ClassRemapper, .Remapper, java.util.*, java.util.regex.Matcher, .Pattern

A plugin that replaces names that are discovered in class files.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
RenamingPlugin.Renaming

A renaming function tho transform a type's binary name.

protected static class
RenamingPlugin.RenamingRemapper

An ASM Remapper to apply renamings.

Field Summary

Modifier and TypeField and Description
private final ElementMatcher<? super TypeDescription>
matcher

A matcher that determines what types to consider for renaming.

private final RenamingPlugin.Renaming
renaming

The renaming to apply.

Constructor Summary

AccessConstructor and Description
public
RenamingPlugin(String
The pattern to consider.
pattern
,
String
The replacement to apply if the supplied pattern is matched.
replacement
)

Creates a renaming plugin for a given regular expression and replacement that applies to all types.

public
RenamingPlugin(String
The pattern to consider.
pattern
,
String
The replacement to apply if the supplied pattern is matched.
replacement
,
String
The prefix for types to consider for renaming.
prefix
)

Creates a renaming plugin for a given regular expression and replacement that applies to all types that start with a given prefix.

public
RenamingPlugin(RenamingPlugin.Renaming
The renaming to apply.
renaming
)

Creates a renaming plugin for the given renaming that applies to all types.

public
RenamingPlugin(RenamingPlugin.Renaming
The renaming to apply.
renaming
,
ElementMatcher<? super TypeDescription>
A matcher that determines what types to consider for renaming.
matcher
)

Creates a renaming plugin for the given renaming and type matcher.

Method Summary

Modifier and TypeMethod and Description
public DynamicType.Builder<?>
apply(DynamicType.Builder<?>
The builder to use as a basis for the applied transformation.
builder
,
TypeDescription
The type being transformed.
typeDescription
,
ClassFileLocator
A class file locator that can locate other types in the scope of the project.
classFileLocator
)

Implements net.bytebuddy.build.Plugin.apply.

Applies this plugin.
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public boolean
matches(TypeDescription
The instance to be matched or null.
target
)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.
public ClassVisitor
wrap(TypeDescription
The instrumented type.
instrumentedType
,
ClassVisitor
A ClassVisitor to become the new primary class visitor to which the created net.bytebuddy.dynamic.DynamicType is written to.
classVisitor
,
Implementation.Context
The implementation context of the current instrumentation.
implementationContext
,
TypePool
The type pool that was provided for the class creation.
typePool
,
FieldList<FieldDescription.InDefinedShape>
The instrumented type's fields.
fields
,
MethodList<?>
The instrumented type's methods non-ignored declared and virtually inherited methods.
methods
,
int
The ASM net.bytebuddy.jar.asm.ClassWriter flags to consider.
writerFlags
,
int
The ASM net.bytebuddy.jar.asm.ClassReader flags to consider.
readerFlags
)

Implements net.bytebuddy.asm.AsmVisitorWrapper.wrap.

Applies a ClassVisitorWrapper to the creation of a net.bytebuddy.dynamic.DynamicType.
Inherited from net.bytebuddy.asm.AsmVisitorWrapper.AbstractBase:
mergeReadermergeWriter

Field Detail

matcherback to summary
private final ElementMatcher<? super TypeDescription> matcher

A matcher that determines what types to consider for renaming.

renamingback to summary
private final RenamingPlugin.Renaming renaming

The renaming to apply.

Constructor Detail

RenamingPluginback to summary
public RenamingPlugin(String pattern, String replacement)

Creates a renaming plugin for a given regular expression and replacement that applies to all types.

Parameters
pattern:String

The pattern to consider.

replacement:String

The replacement to apply if the supplied pattern is matched.

RenamingPluginback to summary
public 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.

Parameters
pattern:String

The pattern to consider.

replacement:String

The replacement to apply if the supplied pattern is matched.

prefix:String

The prefix for types to consider for renaming.

RenamingPluginback to summary
public RenamingPlugin(RenamingPlugin.Renaming renaming)

Creates a renaming plugin for the given renaming that applies to all types.

Parameters
renaming:RenamingPlugin.Renaming

The renaming to apply.

RenamingPluginback to summary
public RenamingPlugin(RenamingPlugin.Renaming renaming, ElementMatcher<? super TypeDescription> matcher)

Creates a renaming plugin for the given renaming and type matcher.

Parameters
renaming:RenamingPlugin.Renaming

The renaming to apply.

matcher:ElementMatcher<? super TypeDescription>

A matcher that determines what types to consider for renaming.

Method Detail

applyback to summary
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)

Implements net.bytebuddy.build.Plugin.apply.

Doc from net.bytebuddy.build.Plugin.apply.

Applies this plugin.

Parameters
builder:DynamicType.Builder<?>

The builder to use as a basis for the applied transformation.

typeDescription:TypeDescription

The type being transformed.

classFileLocator:ClassFileLocator

A class file locator that can locate other types in the scope of the project.

Returns:DynamicType.Builder<?>

The supplied builder with additional transformations registered.

closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

matchesback to summary
public boolean matches(TypeDescription target)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Doc from net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.

Parameters
target:TypeDescription

The instance to be matched or null.

Returns:boolean

true if the given element is matched by this matcher or false otherwise.

wrapback to summary
public ClassVisitor wrap(TypeDescription instrumentedType, ClassVisitor classVisitor, Implementation.Context implementationContext, TypePool typePool, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, int writerFlags, int readerFlags)

Implements net.bytebuddy.asm.AsmVisitorWrapper.wrap.

Doc from net.bytebuddy.asm.AsmVisitorWrapper.wrap.

Applies a ClassVisitorWrapper to the creation of a net.bytebuddy.dynamic.DynamicType.

Parameters
instrumentedType:TypeDescription

The instrumented type.

classVisitor:ClassVisitor

A ClassVisitor to become the new primary class visitor to which the created net.bytebuddy.dynamic.DynamicType is written to.

implementationContext:Implementation.Context

The implementation context of the current instrumentation.

typePool:TypePool

The type pool that was provided for the class creation.

fields:FieldList<FieldDescription.InDefinedShape>

The instrumented type's fields.

methods:MethodList<?>

The instrumented type's methods non-ignored declared and virtually inherited methods.

writerFlags:int

The ASM net.bytebuddy.jar.asm.ClassWriter flags to consider.

readerFlags:int

The ASM net.bytebuddy.jar.asm.ClassReader flags to consider.

Returns:ClassVisitor

A new ClassVisitor that usually delegates to the ClassVisitor delivered in the argument.

net.bytebuddy.build back to summary

public Interface RenamingPlugin.Renaming

Known Direct Implementers
net.bytebuddy.build.RenamingPlugin.Renaming.NoOp, net.bytebuddy.build.RenamingPlugin.Renaming.ForPattern, net.bytebuddy.build.RenamingPlugin.Renaming.Compound

A renaming function tho transform a type's binary name.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
RenamingPlugin.Renaming.ForPattern

A renaming that renames types by a given regular expression.

public static enum
RenamingPlugin.Renaming.NoOp

A non-operational renaming.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

The former name.
apply
(String
The previous name.
name
)

Applies a renaming.

Method Detail

applyback to summary
public String apply(String name)

Applies a renaming.

Parameters
name:String

The previous name.

Returns:String

The former name.

net.bytebuddy.build back to summary

public Class RenamingPlugin.Renaming.Compound

extends Object
implements Renaming
Class Inheritance
All Implemented Interfaces
net.bytebuddy.build.RenamingPlugin.Renaming
Annotations
@Enhance

A compound renaming.

Field Summary

Modifier and TypeField and Description
private final List<RenamingPlugin.Renaming>
renamings

The renamings to apply.

Constructor Summary

AccessConstructor and Description
public
Compound(RenamingPlugin.Renaming...
The renaming to apply.
renaming
)

Creates a new compound renaming.

public
Compound(List<? extends RenamingPlugin.Renaming>
The renamings to apply.
renamings
)

Creates a new compound renaming.

Method Summary

Modifier and TypeMethod and Description
public String
apply(String
The previous name.
name
)

Implements net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Applies a renaming.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

renamingsback to summary
private final List<RenamingPlugin.Renaming> renamings

The renamings to apply.

Constructor Detail

Compoundback to summary
public Compound(RenamingPlugin.Renaming... renaming)

Creates a new compound renaming.

Parameters
renaming:RenamingPlugin.Renaming[]

The renaming to apply.

Compoundback to summary
public Compound(List<? extends RenamingPlugin.Renaming> renamings)

Creates a new compound renaming.

Parameters
renamings:List<? extends RenamingPlugin.Renaming>

The renamings to apply.

Method Detail

applyback to summary
public String apply(String name)

Implements net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Doc from net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Applies a renaming.

Parameters
name:String

The previous name.

Returns:String

The former name.

net.bytebuddy.build back to summary

public Class RenamingPlugin.Renaming.ForPattern

extends Object
implements Renaming
Class Inheritance
All Implemented Interfaces
net.bytebuddy.build.RenamingPlugin.Renaming
Annotations
@Enhance

A renaming that renames types by a given regular expression.

Field Summary

Modifier and TypeField and Description
private final Pattern
pattern

The regular expression to use.

private final String
replacement

The replacement to apply.

Constructor Summary

AccessConstructor and Description
public
ForPattern(Pattern
The regular expression to use.
pattern
,
String
The replacement to apply.
replacement
)

Creates a new renaming for a regular expression.

Method Summary

Modifier and TypeMethod and Description
public String
apply(String
The previous name.
name
)

Implements net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Applies a renaming.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

patternback to summary
private final Pattern pattern

The regular expression to use.

replacementback to summary
private final String replacement

The replacement to apply.

Constructor Detail

ForPatternback to summary
public ForPattern(Pattern pattern, String replacement)

Creates a new renaming for a regular expression.

Parameters
pattern:Pattern

The regular expression to use.

replacement:String

The replacement to apply.

Method Detail

applyback to summary
public String apply(String name)

Implements net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Doc from net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Applies a renaming.

Parameters
name:String

The previous name.

Returns:String

The former name.

net.bytebuddy.build back to summary

public final Enum RenamingPlugin.Renaming.NoOp

extends Enum<RenamingPlugin.Renaming.NoOp>
implements Renaming
Class Inheritance
All Implemented Interfaces
net.bytebuddy.build.RenamingPlugin.Renaming

A non-operational renaming.

Field Summary

Modifier and TypeField and Description
public static final RenamingPlugin.Renaming.NoOp
INSTANCE

The singleton instance.

Constructor Summary

AccessConstructor and Description
private
NoOp()

Method Summary

Modifier and TypeMethod and Description
public String
apply(String
The previous name.
name
)

Implements net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Applies a renaming.
public static RenamingPlugin.Renaming.NoOp
public static RenamingPlugin.Renaming.NoOp[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final RenamingPlugin.Renaming.NoOp INSTANCE

The singleton instance.

Constructor Detail

NoOpback to summary
private NoOp()

Method Detail

applyback to summary
public String apply(String name)

Implements net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Doc from net.bytebuddy.build.RenamingPlugin.Renaming.apply.

Applies a renaming.

Parameters
name:String

The previous name.

Returns:String

The former name.

valueOfback to summary
public static RenamingPlugin.Renaming.NoOp valueOf(String name)
valuesback to summary
public static RenamingPlugin.Renaming.NoOp[] values()
net.bytebuddy.build back to summary

protected Class RenamingPlugin.RenamingRemapper

extends Remapper
Class Inheritance

An ASM Remapper to apply renamings.

Field Summary

Modifier and TypeField and Description
private final Map<String, String>
cache

A cache of previously applied renamings.

private final RenamingPlugin.Renaming
renaming

The renaming to apply.

Constructor Summary

AccessConstructor and Description
protected
RenamingRemapper(RenamingPlugin.Renaming
The renaming to apply.
renaming
)

Creates a new renaming remapper.

Method Summary

Modifier and TypeMethod and Description
public String
map(String
the internal name of a class (see Type#getInternalName()).
internalName
)

Overrides net.bytebuddy.jar.asm.commons.Remapper.map.

Maps the internal name of a class to its new name.
Inherited from net.bytebuddy.jar.asm.commons.Remapper:
createRemappingSignatureAdaptercreateSignatureRemappermapAnnotationAttributeNamemapDescmapFieldNamemapInnerClassNamemapInvokeDynamicMethodNamemapMethodDescmapMethodNamemapModuleNamemapPackageNamemapRecordComponentNamemapSignaturemapTypemapTypesmapValue

Field Detail

cacheback to summary
private final Map<String, String> cache

A cache of previously applied renamings.

renamingback to summary
private final RenamingPlugin.Renaming renaming

The renaming to apply.

Constructor Detail

RenamingRemapperback to summary
protected RenamingRemapper(RenamingPlugin.Renaming renaming)

Creates a new renaming remapper.

Parameters
renaming:RenamingPlugin.Renaming

The renaming to apply.

Method Detail

mapback to summary
public String map(String internalName)

Overrides net.bytebuddy.jar.asm.commons.Remapper.map.

Doc from net.bytebuddy.jar.asm.commons.Remapper.map.

Maps the internal name of a class to its new name. The default implementation of this method returns the given name, unchanged. Subclasses can override.

Parameters
internalName:String

the internal name of a class (see Type#getInternalName()).

Returns:String

the new internal name (see Type#getInternalName()).

Annotations
@Override