Top Description Inners Fields Constructors Methods
net.bytebuddy.build

public Class RepeatedAnnotationPlugin

extends ForElementMatcher
Class Inheritance
Annotations
@Enhance
Imports
edu.umd.cs.findbugs.annotations.SuppressFBWarnings, net.bytebuddy.description.method.MethodDescription, net.bytebuddy.description.type.TypeDescription, net.bytebuddy.dynamic.ClassFileLocator, .DynamicType, net.bytebuddy.implementation.attribute.AnnotationValueFilter, .TypeAttributeAppender, net.bytebuddy.jar.asm.AnnotationVisitor, .ClassVisitor, .Type, java.lang.annotation.*

A plugin that allows for adding a java.lang.annotation.Repeatable annotation even if compiled prior to Java 8 which introduces this annotation. As the annotation is not present on previous JVM versions, it is ignored at runtime for older JVM versions what makes this approach feasible.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static @interface
RepeatedAnnotationPlugin.Enhance

Indicates that the annotated annotation should be repeatable by the supplied annotation.

protected static class
RepeatedAnnotationPlugin.RepeatedAnnotationAppender

A type attribute appender that adds a repeated annotation for a target type.

Field Summary

Modifier and TypeField and Description
private static final MethodDescription.InDefinedShape
VALUE

A description of the Enhance#value() method.

Constructor Summary

AccessConstructor and Description
public
RepeatedAnnotationPlugin()

Creates a new plugin for creating repeated annotations.

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.
Inherited from net.bytebuddy.build.Plugin.ForElementMatcher:
matches

Field Detail

VALUEback to summary
private static final MethodDescription.InDefinedShape VALUE

A description of the Enhance#value() method.

Constructor Detail

RepeatedAnnotationPluginback to summary
public RepeatedAnnotationPlugin()

Creates a new plugin for creating repeated annotations.

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.

Annotations
@SuppressFBWarnings:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
justification:Assuming component type for array type.
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.

net.bytebuddy.build back to summary

public @Interface RepeatedAnnotationPlugin.Enhance

extends Annotation
Annotations
@Documented
@Target:ANNOTATION_TYPE
@Retention:RUNTIME

Indicates that the annotated annotation should be repeatable by the supplied annotation.

Method Summary

Modifier and TypeMethod and Description
public Class<? extends Annotation>

Returns:

The repeating annotation type.
value
()

The repeating annotation type.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public Class<? extends Annotation> value()

The repeating annotation type.

Returns:Class<? extends Annotation>

The repeating annotation type.

net.bytebuddy.build back to summary

protected Class RepeatedAnnotationPlugin.RepeatedAnnotationAppender

extends Object
implements TypeAttributeAppender
Class Inheritance
  • java.lang.Object
  • net.bytebuddy.build.RepeatedAnnotationPlugin.RepeatedAnnotationAppender
All Implemented Interfaces
net.bytebuddy.implementation.attribute.TypeAttributeAppender
Annotations
@Enhance

A type attribute appender that adds a repeated annotation for a target type.

Field Summary

Modifier and TypeField and Description
private final TypeDescription
target

The repeated type.

Constructor Summary

AccessConstructor and Description
protected
RepeatedAnnotationAppender(TypeDescription
The repeated type.
target
)

Creates a new appender.

Method Summary

Modifier and TypeMethod and Description
public void
apply(ClassVisitor
The class visitor to which the annotations of this visitor should be written to.
classVisitor
,
TypeDescription
A description of the instrumented type that is target of the ongoing instrumentation.
instrumentedType
,
AnnotationValueFilter
The annotation value filter to apply when writing annotations.
annotationValueFilter
)

Implements net.bytebuddy.implementation.attribute.TypeAttributeAppender.apply.

Applies this type attribute appender.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

targetback to summary
private final TypeDescription target

The repeated type.

Constructor Detail

RepeatedAnnotationAppenderback to summary
protected RepeatedAnnotationAppender(TypeDescription target)

Creates a new appender.

Parameters
target:TypeDescription

The repeated type.

Method Detail

applyback to summary
public void apply(ClassVisitor classVisitor, TypeDescription instrumentedType, AnnotationValueFilter annotationValueFilter)

Implements net.bytebuddy.implementation.attribute.TypeAttributeAppender.apply.

Doc from net.bytebuddy.implementation.attribute.TypeAttributeAppender.apply.

Applies this type attribute appender.

Parameters
classVisitor:ClassVisitor

The class visitor to which the annotations of this visitor should be written to.

instrumentedType:TypeDescription

A description of the instrumented type that is target of the ongoing instrumentation.

annotationValueFilter:AnnotationValueFilter

The annotation value filter to apply when writing annotations.