Top Description Inners Methods
net.bytebuddy.implementation

public Interface LoadedTypeInitializer

Known Direct Implementers
net.bytebuddy.implementation.LoadedTypeInitializer.NoOp, net.bytebuddy.implementation.LoadedTypeInitializer.ForStaticField, net.bytebuddy.implementation.LoadedTypeInitializer.Compound, net.bytebuddy.agent.builder.AgentBuilder.InitializationStrategy.SelfInjection.Dispatcher.InjectingInitializer
Imports
edu.umd.cs.findbugs.annotations.SuppressFBWarnings, net.bytebuddy.build.AccessControllerPlugin, .HashCodeAndEqualsPlugin, net.bytebuddy.description.type.TypeDescription, net.bytebuddy.utility.JavaModule, net.bytebuddy.utility.nullability.MaybeNull, net.bytebuddy.utility.privilege.SetAccessibleAction, java.io.Serializable, java.lang.reflect.Field, .Modifier, java.security.PrivilegedAction, java.util.ArrayList, .Arrays, .List

Implementations of this interface explicitly initialize a loaded type. Usually, such implementations inject runtime context into an instrumented type which cannot be defined by the means of the Java class file format.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
LoadedTypeInitializer.Compound

A compound loaded type initializer that combines several type initializers.

public static class
LoadedTypeInitializer.ForStaticField

A type initializer for setting a value for a static field.

public static enum
LoadedTypeInitializer.NoOp

A loaded type initializer that does not do anything.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if this initializer is alive.
isAlive
()

Indicates if this initializer is alive and needs to be invoked.

public void
onLoad(Class<?>
The manifestation of the instrumented type.
type
)

Callback that is invoked on the creation of an instrumented type.

Method Detail

isAliveback to summary
public boolean isAlive()

Indicates if this initializer is alive and needs to be invoked. This is only meant as a mark. A loaded type initializer that is not alive might still be called and must therefore not throw an exception but rather provide an empty implementation.

Returns:boolean

true if this initializer is alive.

onLoadback to summary
public void onLoad(Class<?> type)

Callback that is invoked on the creation of an instrumented type. If the loaded type initializer is alive, this method should be implemented empty instead of throwing an exception.

Parameters
type:Class<?>

The manifestation of the instrumented type.

net.bytebuddy.implementation back to summary

public Class LoadedTypeInitializer.Compound

extends Object
implements LoadedTypeInitializer, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, net.bytebuddy.implementation.LoadedTypeInitializer
Annotations
@SuppressFBWarnings:SE_BAD_FIELD
justification:Serialization is considered opt-in for a rare use case
@Enhance

A compound loaded type initializer that combines several type initializers.

Field Summary

Modifier and TypeField and Description
private final List<LoadedTypeInitializer>
loadedTypeInitializers

The loaded type initializers that are represented by this compound type initializer.

private static final long
serialVersionUID

This class's serial version UID.

Constructor Summary

AccessConstructor and Description
public
Compound(LoadedTypeInitializer...
A number of loaded type initializers in their invocation order.
loadedTypeInitializer
)

Creates a new compound loaded type initializer.

public
Compound(List<? extends LoadedTypeInitializer>
A number of loaded type initializers in their invocation order.
loadedTypeInitializers
)

Creates a new compound loaded type initializer.

Method Summary

Modifier and TypeMethod and Description
public boolean
isAlive()

Implements net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Indicates if this initializer is alive and needs to be invoked.
public void
onLoad(Class<?>
The manifestation of the instrumented type.
type
)

Implements net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Callback that is invoked on the creation of an instrumented type.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loadedTypeInitializersback to summary
private final List<LoadedTypeInitializer> loadedTypeInitializers

The loaded type initializers that are represented by this compound type initializer.

Annotations
@SuppressWarnings:serial
serialVersionUIDback to summary
private static final long serialVersionUID

This class's serial version UID.

Constructor Detail

Compoundback to summary
public Compound(LoadedTypeInitializer... loadedTypeInitializer)

Creates a new compound loaded type initializer.

Parameters
loadedTypeInitializer:LoadedTypeInitializer[]

A number of loaded type initializers in their invocation order.

Compoundback to summary
public Compound(List<? extends LoadedTypeInitializer> loadedTypeInitializers)

Creates a new compound loaded type initializer.

Parameters
loadedTypeInitializers:List<? extends LoadedTypeInitializer>

A number of loaded type initializers in their invocation order.

Method Detail

isAliveback to summary
public boolean isAlive()

Implements net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Doc from net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Indicates if this initializer is alive and needs to be invoked. This is only meant as a mark. A loaded type initializer that is not alive might still be called and must therefore not throw an exception but rather provide an empty implementation.

Returns:boolean

true if this initializer is alive.

onLoadback to summary
public void onLoad(Class<?> type)

Implements net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Doc from net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Callback that is invoked on the creation of an instrumented type. If the loaded type initializer is alive, this method should be implemented empty instead of throwing an exception.

Parameters
type:Class<?>

The manifestation of the instrumented type.

net.bytebuddy.implementation back to summary

public Class LoadedTypeInitializer.ForStaticField

extends Object
implements LoadedTypeInitializer, Serializable
Class Inheritance
  • java.lang.Object
  • net.bytebuddy.implementation.LoadedTypeInitializer.ForStaticField
All Implemented Interfaces
java.io.Serializable, net.bytebuddy.implementation.LoadedTypeInitializer
Annotations
@Enhance

A type initializer for setting a value for a static field.

Field Summary

Modifier and TypeField and Description
private final transient Object
accessControlContext

The access control context to use for loading classes or null if the access controller is not available on the current VM.

private final String
fieldName

The name of the field.

private static final long
serialVersionUID

This class's serial version UID.

private final Object
value

The value of the field.

Constructor Summary

AccessConstructor and Description
public
ForStaticField(String
the name of the field.
fieldName
,
Object
The value to be set.
value
)

Creates a new LoadedTypeInitializer for setting a static field.

Method Summary

Modifier and TypeMethod and Description
private static <
The type of the action's resolved value.
T
>
T

Returns:

The action's resolved value.
doPrivileged
(PrivilegedAction<T>
The action to execute from a privileged context.
action
,
Object
The access control context or null if the current VM does not support it.
context
)

A proxy for java.security.AccessController#doPrivileged that is activated if available.

private static Object

Returns:

The current access control context or null if the current VM does not support it.
getContext
()

A proxy for java.security.AccessController#getContext that is activated if available.

public boolean
isAlive()

Implements net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Indicates if this initializer is alive and needs to be invoked.
public void
onLoad(Class<?>
The manifestation of the instrumented type.
type
)

Implements net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Callback that is invoked on the creation of an instrumented type.
private Object

Returns:

A resolved instance of this instance that includes an appropriate access control context.
readResolve
()

Resolves this instance after deserialization to assure the access control context is set.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

accessControlContextback to summary
private final transient Object accessControlContext

The access control context to use for loading classes or null if the access controller is not available on the current VM.

Annotations
@MaybeNull
@ValueHandling:IGNORE
fieldNameback to summary
private final String fieldName

The name of the field.

serialVersionUIDback to summary
private static final long serialVersionUID

This class's serial version UID.

valueback to summary
private final Object value

The value of the field.

Annotations
@SuppressWarnings:serial

Constructor Detail

ForStaticFieldback to summary
public ForStaticField(String fieldName, Object value)

Creates a new LoadedTypeInitializer for setting a static field.

Parameters
fieldName:String

the name of the field.

value:Object

The value to be set.

Method Detail

doPrivilegedback to summary
private static <T> T doPrivileged(PrivilegedAction<T> action, Object context)

A proxy for java.security.AccessController#doPrivileged that is activated if available.

Parameters
<T>
The type of the action's resolved value.
action:PrivilegedAction<T>

The action to execute from a privileged context.

context:Object

The access control context or null if the current VM does not support it.

Returns:T

The action's resolved value.

Annotations
@Enhance
getContextback to summary
private static Object getContext()

A proxy for java.security.AccessController#getContext that is activated if available.

Returns:Object

The current access control context or null if the current VM does not support it.

Annotations
@MaybeNull
@Enhance
isAliveback to summary
public boolean isAlive()

Implements net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Doc from net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Indicates if this initializer is alive and needs to be invoked. This is only meant as a mark. A loaded type initializer that is not alive might still be called and must therefore not throw an exception but rather provide an empty implementation.

Returns:boolean

true if this initializer is alive.

onLoadback to summary
public void onLoad(Class<?> type)

Implements net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Doc from net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Callback that is invoked on the creation of an instrumented type. If the loaded type initializer is alive, this method should be implemented empty instead of throwing an exception.

Parameters
type:Class<?>

The manifestation of the instrumented type.

Annotations
@SuppressFBWarnings:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
justification:Modules are assumed available when module system is supported
readResolveback to summary
private Object readResolve()

Resolves this instance after deserialization to assure the access control context is set.

Returns:Object

A resolved instance of this instance that includes an appropriate access control context.

net.bytebuddy.implementation back to summary

public final Enum LoadedTypeInitializer.NoOp

extends Enum<LoadedTypeInitializer.NoOp>
implements LoadedTypeInitializer
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.LoadedTypeInitializer

A loaded type initializer that does not do anything.

Field Summary

Modifier and TypeField and Description
public static final LoadedTypeInitializer.NoOp
INSTANCE

The singleton instance.

Constructor Summary

AccessConstructor and Description
private
NoOp()

Method Summary

Modifier and TypeMethod and Description
public boolean
isAlive()

Implements net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Indicates if this initializer is alive and needs to be invoked.
public void
onLoad(Class<?>
The manifestation of the instrumented type.
type
)

Implements net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Callback that is invoked on the creation of an instrumented type.
public static LoadedTypeInitializer.NoOp
public static LoadedTypeInitializer.NoOp[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final LoadedTypeInitializer.NoOp INSTANCE

The singleton instance.

Constructor Detail

NoOpback to summary
private NoOp()

Method Detail

isAliveback to summary
public boolean isAlive()

Implements net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Doc from net.bytebuddy.implementation.LoadedTypeInitializer.isAlive.

Indicates if this initializer is alive and needs to be invoked. This is only meant as a mark. A loaded type initializer that is not alive might still be called and must therefore not throw an exception but rather provide an empty implementation.

Returns:boolean

true if this initializer is alive.

onLoadback to summary
public void onLoad(Class<?> type)

Implements net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Doc from net.bytebuddy.implementation.LoadedTypeInitializer.onLoad.

Callback that is invoked on the creation of an instrumented type. If the loaded type initializer is alive, this method should be implemented empty instead of throwing an exception.

Parameters
type:Class<?>

The manifestation of the instrumented type.

valueOfback to summary
public static LoadedTypeInitializer.NoOp valueOf(String name)
valuesback to summary
public static LoadedTypeInitializer.NoOp[] values()