Enum AgentBuilder.DescriptionStrategy.Default
- java.lang.Object
-
- java.lang.Enum<AgentBuilder.DescriptionStrategy.Default>
-
- net.bytebuddy.agent.builder.AgentBuilder.DescriptionStrategy.Default
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<AgentBuilder.DescriptionStrategy.Default>,AgentBuilder.DescriptionStrategy
- Enclosing interface:
- AgentBuilder.DescriptionStrategy
public static enum AgentBuilder.DescriptionStrategy.Default extends java.lang.Enum<AgentBuilder.DescriptionStrategy.Default> implements AgentBuilder.DescriptionStrategy
Default implementations of aAgentBuilder.DescriptionStrategy.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.bytebuddy.agent.builder.AgentBuilder.DescriptionStrategy
AgentBuilder.DescriptionStrategy.Default, AgentBuilder.DescriptionStrategy.SuperTypeLoading
-
-
Enum Constant Summary
Enum Constants Enum Constant Description HYBRIDA description type strategy represents a type as aTypeDescription.ForLoadedTypeif a retransformation or redefinition is applied on a type.POOL_FIRSTA description strategy that always describes Java types using aTypePoolunless a type cannot be resolved by a pool and a loadedClassinstance is available.POOL_ONLYA description strategy that always describes Java types using aTypePool.
-
Field Summary
Fields Modifier and Type Field Description private booleanloadedFirstIndicates if loaded type information is preferred over using a type pool for describing a type.
-
Constructor Summary
Constructors Modifier Constructor Description privateDefault(boolean loadedFirst)Indicates if loaded type information is preferred over using a type pool for describing a type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisLoadedFirst()Indicates if this description strategy makes use of loaded type information and yields a different type description if no loaded type is available.static AgentBuilder.DescriptionStrategy.DefaultvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static AgentBuilder.DescriptionStrategy.Default[]values()Returns an array containing the constants of this enum type, in the order they are declared.AgentBuilder.DescriptionStrategywithSuperTypeLoading()Creates a description strategy that uses this strategy but loads any super type.AgentBuilder.DescriptionStrategywithSuperTypeLoading(java.util.concurrent.ExecutorService executorService)Creates a description strategy that uses this strategy but loads any super type asynchronously.-
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Methods inherited from interface net.bytebuddy.agent.builder.AgentBuilder.DescriptionStrategy
apply
-
-
-
-
Enum Constant Detail
-
HYBRID
public static final AgentBuilder.DescriptionStrategy.Default HYBRID
A description type strategy represents a type as aTypeDescription.ForLoadedTypeif a retransformation or redefinition is applied on a type. Using a loaded type typically results in better performance as no I/O is required for resolving type descriptions. However, any interaction with the type is carried out via the Java reflection API. Using the reflection API triggers eager loading of any type that is part of a method or field signature. If any of these types are missing from the class path, this eager loading will cause aNoClassDefFoundError. Some Java code declares optional dependencies to other classes which are only realized if the optional dependency is present. Such code relies on the Java reflection API not being used for types using optional dependencies.
-
POOL_ONLY
public static final AgentBuilder.DescriptionStrategy.Default POOL_ONLY
A description strategy that always describes Java types using a
TypePool. This requires that any type - even if it is already loaded and aClassinstance is available - is processed as a non-loaded type description. Doing so can cause overhead as processing loaded types is supported very efficiently by a JVM.Avoiding the usage of loaded types can improve robustness as this approach does not rely on the Java reflection API which triggers eager validation of this loaded type which can fail an application if optional types are used by any types field or method signatures. Also, it is possible to guarantee debugging meta data to be available also for retransformed or redefined types if a
AgentBuilder.TypeStrategyspecifies the extraction of such meta data.
-
POOL_FIRST
public static final AgentBuilder.DescriptionStrategy.Default POOL_FIRST
A description strategy that always describes Java types using a
TypePoolunless a type cannot be resolved by a pool and a loadedClassinstance is available. Doing so can cause overhead as processing loaded types is supported very efficiently by a JVM.Avoiding the usage of loaded types can improve robustness as this approach does not rely on the Java reflection API which triggers eager validation of this loaded type which can fail an application if optional types are used by any types field or method signatures. Also, it is possible to guarantee debugging meta data to be available also for retransformed or redefined types if a
AgentBuilder.TypeStrategyspecifies the extraction of such meta data.
-
-
Method Detail
-
values
public static AgentBuilder.DescriptionStrategy.Default[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (AgentBuilder.DescriptionStrategy.Default c : AgentBuilder.DescriptionStrategy.Default.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static AgentBuilder.DescriptionStrategy.Default valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
withSuperTypeLoading
public AgentBuilder.DescriptionStrategy withSuperTypeLoading()
Creates a description strategy that uses this strategy but loads any super type. If a super type is not yet loaded, this causes this super type to never be instrumented. Therefore, this option should only be used if all instrumented types are guaranteed to be top-level types.- Returns:
- This description strategy where all super types are loaded during the instrumentation.
- See Also:
AgentBuilder.DescriptionStrategy.SuperTypeLoading
-
isLoadedFirst
public boolean isLoadedFirst()
Indicates if this description strategy makes use of loaded type information and yields a different type description if no loaded type is available.- Specified by:
isLoadedFirstin interfaceAgentBuilder.DescriptionStrategy- Returns:
trueif this description strategy prefers loaded type information when describing a type and only uses a type pool if loaded type information is not available.
-
withSuperTypeLoading
public AgentBuilder.DescriptionStrategy withSuperTypeLoading(java.util.concurrent.ExecutorService executorService)
Creates a description strategy that uses this strategy but loads any super type asynchronously. Super types are loaded via another thread supplied by the executor service to enforce the instrumentation of any such super type. It is recommended to allow the executor service to create new threads without bound as class loading blocks any thread until all super types were instrumented.- Parameters:
executorService- The executor service to use.- Returns:
- This description strategy where all super types are loaded asynchronously during the instrumentation.
- See Also:
AgentBuilder.DescriptionStrategy.SuperTypeLoading.Asynchronous
-
-