Top Description Inners Methods
org.easymock.bytebuddy.implementation.bind.annotation

public @Interface Origin

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:PARAMETER
Imports
org.easymock.bytebuddy.description.annotation.AnnotationDescription, org.easymock.bytebuddy.description.method.MethodDescription, .MethodList, .ParameterDescription, org.easymock.bytebuddy.description.type.TypeDescription, org.easymock.bytebuddy.implementation.Implementation, org.easymock.bytebuddy.implementation.bind.MethodDelegationBinder, org.easymock.bytebuddy.implementation.bytecode.StackManipulation, org.easymock.bytebuddy.implementation.bytecode.assign.Assigner, org.easymock.bytebuddy.implementation.bytecode.constant.*, org.easymock.bytebuddy.implementation.bytecode.member.MethodInvocation, org.easymock.bytebuddy.utility.JavaConstant, .JavaType, java.lang.annotation.*, java.lang.reflect.Constructor, .Method

The origin annotation provides some meta information about the source method that is bound to this method where the binding is dependant of the parameter's type:

  1. If the annotated parameter is of type java.lang.reflect.Method, java.lang.reflect.Constructor or java.lang.reflect.Executable, the parameter is assigned a reference to the method or constructor it instruments. If the reference is not assignable to the sort of the intercepted source, the target is not considered for binding.
  2. If the annotated parameter is of type java.lang.Class, the parameter is assigned a reference of the type of the instrumented type.
  3. If the annotated parameter is of type java.lang.String, the parameter is assigned a string with the value that would be returned by the Method#toString() method.
  4. If the annotated parameter is a int type, it is assigned the intercepted method's modifiers.
  5. If the annotated type is java.lang.invoke.MethodHandle, a handle of the intercepted method is injected. A java.lang.invoke.MethodHandle is stored in a class's constant pool and does therefore not face the same runtime performance limitations as a (non-cached) java.lang.reflect.Method reference. Method handles are only supported for byte code versions starting from Java 7.
  6. If the annotated type is java.lang.invoke.MethodType, a description of the intercepted method's type is injected. Method type descriptions are only supported for byte code versions starting from Java 7.
  7. If the annotated type is java.lang.invoke.MethodHandles$Lookup, a method handle lookup of the instrumented class is returned. Method type descriptions are only supported for byte code versions starting from Java 7.

Any other parameter type will cause an java.lang.IllegalStateException.

Important Note

A method handle or method type reference can only be used if the referenced method's types are all visible to the instrumented type or an IllegalAccessError will be thrown at runtime.

Important Note

Don't confuse this annotation with org.easymock.bytebuddy.asm.Advice.Origin or org.easymock.bytebuddy.asm.MemberSubstitution.Origin. This annotation should be used with org.easymock.bytebuddy.implementation.MethodDelegation only.

See Also
net.bytebuddy.implementation.MethodDelegation, net.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Origin.Binder

A binder for binding parameters that are annotated with org.easymock.bytebuddy.implementation.bind.annotation.Origin.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the value for this parameter should be cached in a static field inside the instrumented class.
cache
()

Determines if the value that is assigned by this annotation is cached.

public boolean

Returns:

true if the class should be looked up using an java.security.AccessController.
privileged
()

Determines if the method should be resolved by using an java.security.AccessController using the privileges of the generated class.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

cacheback to summary
public boolean cache()

Determines if the value that is assigned by this annotation is cached. For values that can be stored in the constant pool, this value is ignored as such values are cached implicitly. As a result, this value currently only affects caching of Method instances.

Returns:boolean

true if the value for this parameter should be cached in a static field inside the instrumented class.

privilegedback to summary
public boolean privileged()

Determines if the method should be resolved by using an java.security.AccessController using the privileges of the generated class. Doing so requires the generation of an auxiliary class that implements java.security.PrivilegedExceptionAction.

Returns:boolean

true if the class should be looked up using an java.security.AccessController.

org.easymock.bytebuddy.implementation.bind.annotation back to summary

public final Enum Origin.Binder

extends Enum<Origin.Binder>
implements TargetMethodAnnotationDrivenBinder.ParameterBinder<Origin>
Class Inheritance
All Implemented Interfaces
org.easymock.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder

A binder for binding parameters that are annotated with org.easymock.bytebuddy.implementation.bind.annotation.Origin.
See Also
TargetMethodAnnotationDrivenBinder

Field Summary

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

A description of the Origin#cache() method.

public static final Origin.Binder
INSTANCE

The singleton instance.

private static final MethodDescription.InDefinedShape
PRIVILEGED

A description of the Origin#privileged() method.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MethodDelegationBinder.ParameterBinding<?>
bind(AnnotationDescription.Loadable<Origin>
The annotation that was cause for the delegation to this argument binder.
annotation
,
MethodDescription
The intercepted source method.
source
,
ParameterDescription
Tge target parameter that is subject to be bound to intercepting the source method.
target
,
Implementation.Target
The target of the current implementation that is subject to this binding.
implementationTarget
,
Assigner
An assigner that can be used for applying the binding.
assigner
,
Assigner.Typing
The typing to apply.
typing
)

Implements org.easymock.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.bind.

Creates a parameter binding for the given target parameter.
public Class<Origin>
private static StackManipulation

Returns:

An appropriate stack manipulation.
methodConstant
(AnnotationDescription.Loadable<Origin>
The origin annotation.
annotation
,
MethodDescription.InDefinedShape
The method description to load.
methodDescription
)

Loads a method constant onto the operand stack.

public static Origin.Binder
public static Origin.Binder[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CACHEback to summary
private static final MethodDescription.InDefinedShape CACHE

A description of the Origin#cache() method.

INSTANCEback to summary
public static final Origin.Binder INSTANCE

The singleton instance.

PRIVILEGEDback to summary
private static final MethodDescription.InDefinedShape PRIVILEGED

A description of the Origin#privileged() method.

Constructor Detail

Binderback to summary
private Binder()

Method Detail

bindback to summary
public MethodDelegationBinder.ParameterBinding<?> bind(AnnotationDescription.Loadable<Origin> annotation, MethodDescription source, ParameterDescription target, Implementation.Target implementationTarget, Assigner assigner, Assigner.Typing typing)

Implements org.easymock.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.bind.

Doc from org.easymock.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.bind.

Creates a parameter binding for the given target parameter.

Parameters
annotation:AnnotationDescription.Loadable<Origin>

The annotation that was cause for the delegation to this argument binder.

source:MethodDescription

The intercepted source method.

target:ParameterDescription

Tge target parameter that is subject to be bound to intercepting the source method.

implementationTarget:Implementation.Target

The target of the current implementation that is subject to this binding.

assigner:Assigner

An assigner that can be used for applying the binding.

typing:Assigner.Typing

The typing to apply.

Returns:MethodDelegationBinder.ParameterBinding<?>

A parameter binding for the requested target method parameter.

getHandledTypeback to summary
public Class<Origin> getHandledType()

Implements org.easymock.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.getHandledType.

Doc from org.easymock.bytebuddy.implementation.bind.annotation.TargetMethodAnnotationDrivenBinder.ParameterBinder.getHandledType.

The annotation type that is handled by this parameter binder.

Returns:Class<Origin>

The java.lang.annotation.Annotation#annotationType() handled by this parameter binder.

methodConstantback to summary
private static StackManipulation methodConstant(AnnotationDescription.Loadable<Origin> annotation, MethodDescription.InDefinedShape methodDescription)

Loads a method constant onto the operand stack.

Parameters
annotation:AnnotationDescription.Loadable<Origin>

The origin annotation.

methodDescription:MethodDescription.InDefinedShape

The method description to load.

Returns:StackManipulation

An appropriate stack manipulation.

valueOfback to summary
public static Origin.Binder valueOf(String name)
valuesback to summary
public static Origin.Binder[] values()