Top Description Inners Methods
net.bytebuddy.implementation.bind.annotation

public @Interface RuntimeType

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:PARAMETER, METHOD
Imports
net.bytebuddy.description.annotation.AnnotationSource, net.bytebuddy.implementation.bytecode.assign.Assigner, java.lang.annotation.*

Parameters that are annotated with this annotation will be assigned by also considering the runtime type of the target parameter. The same is true for a method's return type if a target method is annotated with this annotation.

 

For example, if a source method foo(Object) is attempted to be bound to bar(@RuntimeType String), the binding will attempt to cast the argument of foo to a String type before calling bar with this argument. If this is not possible, a java.lang.ClassCastException will be thrown at runtime. Similarly, if a method foo returns a type String but is bound to a method that returns a type Object, annotating the target method with @RuntimeType results in the foo method casting the target's method return value to String before returning a value itself.
See Also
net.bytebuddy.implementation.MethodDelegation, net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
RuntimeType.Verifier

A non-instantiable type that allows to check if a method or parameter should consider a runtime type.

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString
net.bytebuddy.implementation.bind.annotation back to summary

public final Class RuntimeType.Verifier

extends Object
Class Inheritance
  • java.lang.Object
  • net.bytebuddy.implementation.bind.annotation.RuntimeType.Verifier

A non-instantiable type that allows to check if a method or parameter should consider a runtime type.

Constructor Summary

AccessConstructor and Description
private
Verifier()

As this is merely a utility method, the constructor is not supposed to be invoked.

Method Summary

Modifier and TypeMethod and Description
public static Assigner.Typing

Returns:

Indicates if dynamic type castings should be attempted for incompatible assignments.
check
(AnnotationSource
The annotated element of interest.
annotationSource
)

Checks if an annotated element should be assigned a value by considering the runtime type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Verifierback to summary
private Verifier()

As this is merely a utility method, the constructor is not supposed to be invoked.

Method Detail

checkback to summary
public static Assigner.Typing check(AnnotationSource annotationSource)

Checks if an annotated element should be assigned a value by considering the runtime type.

Parameters
annotationSource:AnnotationSource

The annotated element of interest.

Returns:Assigner.Typing

Indicates if dynamic type castings should be attempted for incompatible assignments.