Top Description Inners Fields Constructors Methods
org.easymock.bytebuddy.implementation

public Class ExceptionMethod

extends Object
implements Implementation, ByteCodeAppender
Class Inheritance
All Implemented Interfaces
org.easymock.bytebuddy.implementation.bytecode.ByteCodeAppender, org.easymock.bytebuddy.implementation.Implementation, org.easymock.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable
Annotations
@Enhance
Imports
org.easymock.bytebuddy.build.HashCodeAndEqualsPlugin, org.easymock.bytebuddy.description.method.MethodDescription, org.easymock.bytebuddy.description.type.TypeDescription, org.easymock.bytebuddy.dynamic.scaffold.InstrumentedType, org.easymock.bytebuddy.implementation.bytecode.*, org.easymock.bytebuddy.implementation.bytecode.constant.TextConstant, org.easymock.bytebuddy.implementation.bytecode.member.MethodInvocation, org.easymock.bytebuddy.jar.asm.MethodVisitor

This implementation causes a java.lang.Throwable to be thrown when the instrumented method is invoked. Be aware that the Java Virtual machine does not care about exception declarations and will throw any java.lang.Throwable from any method even if the method does not declared a checked exception.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ExceptionMethod.ConstructionDelegate

A construction delegate is responsible for calling a Throwable's constructor.

Field Summary

Modifier and TypeField and Description
private final ExceptionMethod.ConstructionDelegate
constructionDelegate

The construction delegation which is responsible for creating the exception to be thrown.

Constructor Summary

AccessConstructor and Description
public
ExceptionMethod(ExceptionMethod.ConstructionDelegate
A delegate that is responsible for calling the Throwable's constructor.
constructionDelegate
)

Creates a new instance of an implementation for throwing throwables.

Method Summary

Modifier and TypeMethod and Description
public ByteCodeAppender
appender(Implementation.Target
The target of the current implementation.
implementationTarget
)

Implements org.easymock.bytebuddy.implementation.Implementation.appender.

Creates a byte code appender that determines the implementation of the instrumented type's methods.
public ByteCodeAppender.Size
apply(MethodVisitor
The method visitor to which the byte code appender writes its code to.
methodVisitor
,
Implementation.Context
The implementation context of the current type creation process.
implementationContext
,
MethodDescription
The method that is the target of the instrumentation.
instrumentedMethod
)

Implements org.easymock.bytebuddy.implementation.bytecode.ByteCodeAppender.apply.

Applies this byte code appender to a type creation process.
public InstrumentedType
prepare(InstrumentedType
The instrumented type in its current form.
instrumentedType
)

Implements org.easymock.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable.prepare.

Prepares a given instrumented type.
public static Implementation

Returns:

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.
throwing
(Class<? extends Throwable>
The type of the Throwable.
throwableType
)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately.

public static Implementation

Returns:

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.
throwing
(TypeDescription
The type of the Throwable.
throwableType
)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately.

public static Implementation

Returns:

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.
throwing
(Class<? extends Throwable>
The type of the Throwable.
throwableType
,
String
The string that is handed to the constructor. Usually an exception message.
message
)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately.

public static Implementation

Returns:

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.
throwing
(TypeDescription
The type of the Throwable.
throwableType
,
String
The string that is handed to the constructor. Usually an exception message.
message
)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

constructionDelegateback to summary
private final ExceptionMethod.ConstructionDelegate constructionDelegate

The construction delegation which is responsible for creating the exception to be thrown.

Constructor Detail

ExceptionMethodback to summary
public ExceptionMethod(ExceptionMethod.ConstructionDelegate constructionDelegate)

Creates a new instance of an implementation for throwing throwables.

Parameters
constructionDelegate:ExceptionMethod.ConstructionDelegate

A delegate that is responsible for calling the Throwable's constructor.

Method Detail

appenderback to summary
public ByteCodeAppender appender(Implementation.Target implementationTarget)

Implements org.easymock.bytebuddy.implementation.Implementation.appender.

Doc from org.easymock.bytebuddy.implementation.Implementation.appender.

Creates a byte code appender that determines the implementation of the instrumented type's methods.

Parameters
implementationTarget:Implementation.Target

The target of the current implementation.

Returns:ByteCodeAppender

A byte code appender for implementing methods delegated to this implementation. This byte code appender is also responsible for handling methods that were added by this implementation on the call to Implementation#prepare(InstrumentedType).

applyback to summary
public ByteCodeAppender.Size apply(MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod)

Implements org.easymock.bytebuddy.implementation.bytecode.ByteCodeAppender.apply.

Doc from org.easymock.bytebuddy.implementation.bytecode.ByteCodeAppender.apply.

Applies this byte code appender to a type creation process.

Parameters
methodVisitor:MethodVisitor

The method visitor to which the byte code appender writes its code to.

implementationContext:Implementation.Context

The implementation context of the current type creation process.

instrumentedMethod:MethodDescription

The method that is the target of the instrumentation.

Returns:ByteCodeAppender.Size

The required size for the applied byte code to run.

prepareback to summary
public InstrumentedType prepare(InstrumentedType instrumentedType)

Implements org.easymock.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable.prepare.

Doc from org.easymock.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable.prepare.

Prepares a given instrumented type.

Parameters
instrumentedType:InstrumentedType

The instrumented type in its current form.

Returns:InstrumentedType

The prepared instrumented type.

throwingback to summary
public static Implementation throwing(Class<? extends Throwable> throwableType)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately. For this to be possible, the given type must define a default constructor which is visible from the instrumented type.

Parameters
throwableType:Class<? extends Throwable>

The type of the Throwable.

Returns:Implementation

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.

throwingback to summary
public static Implementation throwing(TypeDescription throwableType)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately. For this to be possible, the given type must define a default constructor which is visible from the instrumented type.

Parameters
throwableType:TypeDescription

The type of the Throwable.

Returns:Implementation

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.

throwingback to summary
public static Implementation throwing(Class<? extends Throwable> throwableType, String message)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately. For this to be possible, the given type must define a constructor that takes a single java.lang.String as its argument.

Parameters
throwableType:Class<? extends Throwable>

The type of the Throwable.

message:String

The string that is handed to the constructor. Usually an exception message.

Returns:Implementation

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.

throwingback to summary
public static Implementation throwing(TypeDescription throwableType, String message)

Creates an implementation that creates a new instance of the given Throwable type on each method invocation which is then thrown immediately. For this to be possible, the given type must define a constructor that takes a single java.lang.String as its argument.

Parameters
throwableType:TypeDescription

The type of the Throwable.

message:String

The string that is handed to the constructor. Usually an exception message.

Returns:Implementation

An implementation that will throw an instance of the Throwable on each method invocation of the instrumented methods.

org.easymock.bytebuddy.implementation back to summary

public Interface ExceptionMethod.ConstructionDelegate

Known Direct Implementers
org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.ForDefaultConstructor, org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.ForStringConstructor

A construction delegate is responsible for calling a Throwable's constructor.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ExceptionMethod.ConstructionDelegate.ForDefaultConstructor

A construction delegate that calls the default constructor.

public static class
ExceptionMethod.ConstructionDelegate.ForStringConstructor

A construction delegate that calls a constructor that takes a single string as its argument.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation

Returns:

A stack manipulation for constructing a Throwable.
make
()

Creates a stack manipulation that creates pushes all constructor arguments onto the operand stack and subsequently calls the constructor.

Method Detail

makeback to summary
public StackManipulation make()

Creates a stack manipulation that creates pushes all constructor arguments onto the operand stack and subsequently calls the constructor.

Returns:StackManipulation

A stack manipulation for constructing a Throwable.

org.easymock.bytebuddy.implementation back to summary

public Class ExceptionMethod.ConstructionDelegate.ForDefaultConstructor

extends Object
implements ConstructionDelegate
Class Inheritance
  • java.lang.Object
  • org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.ForDefaultConstructor
All Implemented Interfaces
org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate
Annotations
@Enhance

A construction delegate that calls the default constructor.

Field Summary

Modifier and TypeField and Description
private final MethodDescription
targetConstructor

The constructor that is used for creating the exception.

private final TypeDescription
throwableType

The type of the exception that is to be thrown.

Constructor Summary

AccessConstructor and Description
public
ForDefaultConstructor(TypeDescription
The type of the Throwable.
throwableType
)

Creates a new construction delegate that calls a default constructor.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation
make()

Implements org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.make.

Creates a stack manipulation that creates pushes all constructor arguments onto the operand stack and subsequently calls the constructor.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

targetConstructorback to summary
private final MethodDescription targetConstructor

The constructor that is used for creating the exception.

throwableTypeback to summary
private final TypeDescription throwableType

The type of the exception that is to be thrown.

Constructor Detail

ForDefaultConstructorback to summary
public ForDefaultConstructor(TypeDescription throwableType)

Creates a new construction delegate that calls a default constructor.

Parameters
throwableType:TypeDescription

The type of the Throwable.

Method Detail

makeback to summary
public StackManipulation make()

Implements org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.make.

Doc from org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.make.

Creates a stack manipulation that creates pushes all constructor arguments onto the operand stack and subsequently calls the constructor.

Returns:StackManipulation

A stack manipulation for constructing a Throwable.

org.easymock.bytebuddy.implementation back to summary

public Class ExceptionMethod.ConstructionDelegate.ForStringConstructor

extends Object
implements ConstructionDelegate
Class Inheritance
  • java.lang.Object
  • org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.ForStringConstructor
All Implemented Interfaces
org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate
Annotations
@Enhance

A construction delegate that calls a constructor that takes a single string as its argument.

Field Summary

Modifier and TypeField and Description
private final String
message

The java.lang.String that is to be passed to the exception's constructor.

private final MethodDescription
targetConstructor

The constructor that is used for creating the exception.

private final TypeDescription
throwableType

The type of the exception that is to be thrown.

Constructor Summary

AccessConstructor and Description
public
ForStringConstructor(TypeDescription
The type of the Throwable.
throwableType
,
String
The string that is handed to the constructor.
message
)

Creates a new construction delegate that calls a constructor by handing it the given string.

Method Summary

Modifier and TypeMethod and Description
public StackManipulation
make()

Implements org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.make.

Creates a stack manipulation that creates pushes all constructor arguments onto the operand stack and subsequently calls the constructor.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

messageback to summary
private final String message

The java.lang.String that is to be passed to the exception's constructor.

targetConstructorback to summary
private final MethodDescription targetConstructor

The constructor that is used for creating the exception.

throwableTypeback to summary
private final TypeDescription throwableType

The type of the exception that is to be thrown.

Constructor Detail

ForStringConstructorback to summary
public ForStringConstructor(TypeDescription throwableType, String message)

Creates a new construction delegate that calls a constructor by handing it the given string.

Parameters
throwableType:TypeDescription

The type of the Throwable.

message:String

The string that is handed to the constructor.

Method Detail

makeback to summary
public StackManipulation make()

Implements org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.make.

Doc from org.easymock.bytebuddy.implementation.ExceptionMethod.ConstructionDelegate.make.

Creates a stack manipulation that creates pushes all constructor arguments onto the operand stack and subsequently calls the constructor.

Returns:StackManipulation

A stack manipulation for constructing a Throwable.