Package net.bytebuddy.implementation
Class ExceptionMethod
java.lang.Object
net.bytebuddy.implementation.ExceptionMethod
- All Implemented Interfaces:
InstrumentedType.Prepareable,ByteCodeAppender,Implementation
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA construction delegate is responsible for calling aThrowable's constructor.Nested classes/interfaces inherited from interface net.bytebuddy.implementation.bytecode.ByteCodeAppender
ByteCodeAppender.Compound, ByteCodeAppender.Simple, ByteCodeAppender.SizeNested classes/interfaces inherited from interface net.bytebuddy.implementation.Implementation
Implementation.Composable, Implementation.Compound, Implementation.Context, Implementation.Simple, Implementation.SpecialMethodInvocation, Implementation.TargetNested classes/interfaces inherited from interface net.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable
InstrumentedType.Prepareable.NoOp -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ExceptionMethod.ConstructionDelegateThe construction delegation which is responsible for creating the exception to be thrown. -
Constructor Summary
ConstructorsConstructorDescriptionExceptionMethod(ExceptionMethod.ConstructionDelegate constructionDelegate) Creates a new instance of an implementation for throwing throwables. -
Method Summary
Modifier and TypeMethodDescriptionappender(Implementation.Target implementationTarget) Creates a byte code appender that determines the implementation of the instrumented type's methods.apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) Applies this byte code appender to a type creation process.prepare(InstrumentedType instrumentedType) Prepares a given instrumented type.static ImplementationCreates an implementation that creates a new instance of the givenThrowabletype on each method invocation which is then thrown immediately.static ImplementationCreates an implementation that creates a new instance of the givenThrowabletype on each method invocation which is then thrown immediately.static Implementationthrowing(TypeDescription throwableType) Creates an implementation that creates a new instance of the givenThrowabletype on each method invocation which is then thrown immediately.static Implementationthrowing(TypeDescription throwableType, String message) Creates an implementation that creates a new instance of the givenThrowabletype on each method invocation which is then thrown immediately.
-
Field Details
-
constructionDelegate
The construction delegation which is responsible for creating the exception to be thrown.
-
-
Constructor Details
-
ExceptionMethod
Creates a new instance of an implementation for throwing throwables.- Parameters:
constructionDelegate- A delegate that is responsible for calling theThrowable's constructor.
-
-
Method Details
-
throwing
Creates an implementation that creates a new instance of the givenThrowabletype 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. -
throwing
Creates an implementation that creates a new instance of the givenThrowabletype 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. -
throwing
-
throwing
-
prepare
Prepares a given instrumented type.- Specified by:
preparein interfaceInstrumentedType.Prepareable- Parameters:
instrumentedType- The instrumented type in its current form.- Returns:
- The prepared instrumented type.
-
appender
Creates a byte code appender that determines the implementation of the instrumented type's methods.- Specified by:
appenderin interfaceImplementation- Parameters:
implementationTarget- The target of the current implementation.- Returns:
- 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
InstrumentedType.Prepareable.prepare(InstrumentedType).
-
apply
public ByteCodeAppender.Size apply(org.objectweb.asm.MethodVisitor methodVisitor, Implementation.Context implementationContext, MethodDescription instrumentedMethod) Applies this byte code appender to a type creation process.- Specified by:
applyin interfaceByteCodeAppender- Parameters:
methodVisitor- The method visitor to which the byte code appender writes its code to.implementationContext- The implementation context of the current type creation process.instrumentedMethod- The method that is the target of the instrumentation.- Returns:
- The required size for the applied byte code to run.
-