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
public static interface Implementation.Context extends MethodAccessorFactory
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 aMethodVisitor
. As such, an implementation context and aMethodVisitor
are complementary for creating an new Java type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Implementation.Context.Default
A default implementation of anImplementation.Context.ExtractableView
which serves as its ownMethodAccessorFactory
.static class
Implementation.Context.Disabled
An implementation context that does not allow for any injections into the static initializer block.static interface
Implementation.Context.ExtractableView
Represents an extractable view of anImplementation.Context
which allows the retrieval of any registered auxiliary type.static interface
Implementation.Context.Factory
A factory for creating a new implementation context.-
Nested classes/interfaces inherited from interface net.bytebuddy.implementation.MethodAccessorFactory
MethodAccessorFactory.AccessType, MethodAccessorFactory.Illegal
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description FieldDescription.InDefinedShape
cache(StackManipulation fieldValue, TypeDescription fieldType)
Caches a single value by storing it in form of aprivate
,final
andstatic
field.ClassFileVersion
getClassFileVersion()
Returns the class file version of the currently created dynamic type.TypeDescription
getInstrumentedType()
Returns the instrumented type of the current implementation.TypeDescription
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 Detail
-
register
TypeDescription register(AuxiliaryType auxiliaryType)
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
FieldDescription.InDefinedShape cache(StackManipulation fieldValue, TypeDescription fieldType)
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 created dynamic type.- Returns:
- The class file version of the currently created dynamic type.
-
-