Class BytecodeTransformerBuildItem
- java.lang.Object
-
- io.quarkus.builder.item.BuildItem
-
- io.quarkus.builder.item.MultiBuildItem
-
- io.quarkus.deployment.builditem.BytecodeTransformerBuildItem
-
public final class BytecodeTransformerBuildItem extends MultiBuildItem
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BytecodeTransformerBuildItem.Builder
-
Field Summary
Fields Modifier and Type Field Description (package private) boolean
cacheable
(package private) int
classReaderOptions
(package private) String
classToTransform
(package private) boolean
continueOnFailure
(package private) boolean
eager
If this is true it means the class should be loaded eagerly by a thread pool in dev mode on multithreaded systems.(package private) BiFunction<String,byte[],byte[]>
inputTransformer
Function that can be applied to the inout bytes before it is passed into ASM.(package private) int
priority
(package private) Set<String>
requireConstPoolEntry
A set of class names that need to be present in the const pool for the transformation to happen.(package private) BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor>
visitorFunction
-
Constructor Summary
Constructors Constructor Description BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction)
BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, boolean cacheable)
BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry)
BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry, boolean cacheable)
BytecodeTransformerBuildItem(BytecodeTransformerBuildItem.Builder builder)
BytecodeTransformerBuildItem(String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction)
BytecodeTransformerBuildItem(String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getClassReaderOptions()
String
getClassToTransform()
BiFunction<String,byte[],byte[]>
getInputTransformer()
int
getPriority()
Bytecode transformers are applied in ascending priority order.Set<String>
getRequireConstPoolEntry()
BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor>
getVisitorFunction()
boolean
isCacheable()
boolean
isContinueOnFailure()
boolean
isEager()
-
-
-
Field Detail
-
eager
final boolean eager
If this is true it means the class should be loaded eagerly by a thread pool in dev mode on multithreaded systems.Transformation is expensive, so doing it this way can speed up boot time.
-
classToTransform
final String classToTransform
-
visitorFunction
final BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction
-
inputTransformer
final BiFunction<String,byte[],byte[]> inputTransformer
Function that can be applied to the inout bytes before it is passed into ASM. This should only be used in very specific circumstances. At the moment the only known valid use case is jacoco, which needs access to the unmodified class file bytes.
-
requireConstPoolEntry
final Set<String> requireConstPoolEntry
A set of class names that need to be present in the const pool for the transformation to happen. These need to be in JVM internal format.The transformation is only applied if at least one of the entries in the const pool is present
Note that this is an optimisation, and if another transformer is transforming the class anyway then this transformer will always be applied.
-
cacheable
final boolean cacheable
-
classReaderOptions
final int classReaderOptions
-
continueOnFailure
final boolean continueOnFailure
-
priority
final int priority
-
-
Constructor Detail
-
BytecodeTransformerBuildItem
public BytecodeTransformerBuildItem(String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction)
-
BytecodeTransformerBuildItem
public BytecodeTransformerBuildItem(String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry)
-
BytecodeTransformerBuildItem
public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction)
-
BytecodeTransformerBuildItem
public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, boolean cacheable)
-
BytecodeTransformerBuildItem
public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry)
-
BytecodeTransformerBuildItem
public BytecodeTransformerBuildItem(boolean eager, String classToTransform, BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> visitorFunction, Set<String> requireConstPoolEntry, boolean cacheable)
-
BytecodeTransformerBuildItem
public BytecodeTransformerBuildItem(BytecodeTransformerBuildItem.Builder builder)
-
-
Method Detail
-
getClassToTransform
public String getClassToTransform()
-
getVisitorFunction
public BiFunction<String,org.objectweb.asm.ClassVisitor,org.objectweb.asm.ClassVisitor> getVisitorFunction()
-
isEager
public boolean isEager()
-
isCacheable
public boolean isCacheable()
-
getClassReaderOptions
public int getClassReaderOptions()
-
getInputTransformer
public BiFunction<String,byte[],byte[]> getInputTransformer()
-
isContinueOnFailure
public boolean isContinueOnFailure()
-
getPriority
public int getPriority()
Bytecode transformers are applied in ascending priority order. That is, lower priority value means the transformer is applied sooner, and higher priority value means the transformer is applied later.This applies directly to
inputTransformer
functions: an input transformer function with lower priority is applied first and its result is passed to the transformer function with higher priority.It is a bit counter-intuitive when it comes to the
visitorFunction
. The visitor function doesn't directly transform bytecode; instead, it constructs an ASMClassVisitor
from an earlier class visitor. This means that the priority order is effectively turned around: the later a bytecode transformer is called, the higher in the class visitor chain it ends up, and the sooner is the visitor eventually called.The priority value defaults to
0
.
-
-