Package net.bytebuddy.implementation
Interface Implementation.Context
- All Superinterfaces:
MethodAccessorFactory
- All Known Subinterfaces:
Implementation.Context.ExtractableView
- All Known Implementing Classes:
Implementation.Context.Default
,Implementation.Context.Disabled
,Implementation.Context.ExtractableView.AbstractBase
- Enclosing interface:
Implementation
The context for an implementation application. An implementation context represents a mutable data structure
where any registration is irrevocable. Calling methods on an implementation context should be considered equally
sensitive as calling a
MethodVisitor
. As such, an implementation context and a
MethodVisitor
are complementary for creating an new Java type.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic class
A default implementation of anImplementation.Context.ExtractableView
which serves as its ownMethodAccessorFactory
.static class
An implementation context that does not allow for any injections into the static initializer block.static interface
Represents an extractable view of anImplementation.Context
which allows the retrieval of any registered auxiliary type.static interface
A factory for creating a new implementation context.static enum
Indicates the frame generation being applied.Nested classes/interfaces inherited from interface net.bytebuddy.implementation.MethodAccessorFactory
MethodAccessorFactory.AccessType, MethodAccessorFactory.Illegal
-
Method Summary
Modifier and TypeMethodDescriptioncache
(StackManipulation fieldValue, TypeDescription fieldType) Caches a single value by storing it in form of aprivate
,final
andstatic
field.Returns the class file version of the currently creatgetClassFileVersioned dynamic type.Returnstrue
if the explicit generation of stack map frames is expected.Returns the instrumented type of the current implementation.register
(AuxiliaryType auxiliaryType) Registers an auxiliary type as required for the current implementation.Methods inherited from interface net.bytebuddy.implementation.MethodAccessorFactory
registerAccessorFor, registerGetterFor, registerSetterFor
-
Method Details
-
register
Registers an auxiliary type as required for the current implementation. Registering a type will cause the creation of this type even if this type is not effectively used for the current implementation.- Parameters:
auxiliaryType
- The auxiliary type that is required for the current implementation.- Returns:
- A description of the registered auxiliary type.
-
cache
Caches a single value by storing it in form of aprivate
,final
andstatic
field. By caching values, expensive instance creations can be avoided and object identity can be preserved. The field is initiated in a generated class's static initializer.- Parameters:
fieldValue
- A stack manipulation for creating the value that is to be cached in astatic
field. After executing the stack manipulation, exactly one value must be put onto the operand stack which is assignable to the givenfieldType
.fieldType
- The type of the field for storing the cached value. This field's type determines the value that is put onto the operand stack by this method's returned stack manipulation.- Returns:
- A description of a field that was defined on the instrumented type which contains the given value.
-
getInstrumentedType
TypeDescription getInstrumentedType()Returns the instrumented type of the current implementation. The instrumented type is exposed with the intend of allowing optimal byte code generation and not for implementing checks or changing the behavior of aStackManipulation
.- Returns:
- The instrumented type of the current implementation.
-
getClassFileVersion
ClassFileVersion getClassFileVersion()Returns the class file version of the currently creatgetClassFileVersioned dynamic type.- Returns:
- The class file version of the currently created dynamic type.
-
getFrameGeneration
Implementation.Context.FrameGeneration getFrameGeneration()Returnstrue
if the explicit generation of stack map frames is expected.- Returns:
true
if the explicit generation of stack map frames is expected.
-